Classic 10 Balls into 4 boxes problem

2.6k Views Asked by At

Question:Throw at random 10 balls into 4 boxes. What is the probability that exactly 2 boxes remain empty?

My Solution: Using the stars and bars method, the boxes and balls can be thought as $0$ and | e.g. one configuration would be $$ 000000|00|0|0 $$ which would represent 6 balls in the first box etc. Thus the total number of configurations would be $\binom{13}{3}=286.$

There are $\binom{4}{2}$ to have 2 out of the 4 boxes empty, then to ensure the balls are put into only the other two boxes you place 1 ball into the other two boxes and then distribute the remaining 8 balls into the 2 boxes, which, using the same method as above, gives $\binom{9}{1}$ ways. Therefore there are $\binom{4}{2}*\binom{9}{1}=54$ ways of having exactly two boxes empty, giving a probability of $54/286\approx0.189.$

I did a simulation in MATLAB to confirm the answer, to find that I get a probability of $\approx0.005$, way off my answer. I can't see why my code and my solution above disagree so I'll post my code Here

2

There are 2 best solutions below

0
On BEST ANSWER

Temporarily assume the balls are labelled. This allows us to look at the sample space $\{1,2,3,4\}^{10}$ of size $4^{10}$ which will happen to be equiprobable, allowing us to use counting methods. (the sample space of size $\binom{13}{3}=286$ where the balls are indistinct is not equiprobable and so we may not use elementary counting methods with this choice)

Break apart via multiplication principle.

  • Pick which two boxes are empty. $\binom{4}{2}$
  • Pick how the balls are arranged among the two non-empty boxes.
    • To do so, ignore the condition that they be non-empty: there are $2^{10}$ choices
    • Then, remove the "bad" arrangements, where all ten are in the same box leaving the other empty. There are $2$ bad arrangements
    • This gives a total of $2^{10}-2$ ways to arrange among two boxes.

Applying multiplication principle then, there are $\binom{4}{2}(2^{10}-2)=6132$ ways to arrange the ten balls among the four boxes having exactly two boxes empty.

Dividing by the size of the sample space then, the probability is:

$$\frac{6132}{4^{10}}\approx 0.0058479$$

much more closely matching your simulation.

0
On

Generalizing (using urns instead of boxes, to make the variables a little easier to name):

How many ways are there to distribute $b$ unlabeled balls into $u$ urns such that exactly $k$ of those urns are empty?

Choose exactly $u-k$ urns that won’t be empty, group the $b$ balls into $u-k$ sets with at least $1$ ball in each group, and then count the number of ways to distribute those groups among the $u-k$ non-empty urns.

To get the probability, divide by $u^b$, since each of the $b$ balls can be allocated among any of the $u$ urns.

$$P(b, u, k) = \frac{\binom{u}{u-k}{b \brace u-k}(u-k)!}{u^b}$$

Where ${n \brace k}$ is a Stirling number of the second kind.

$$P(10,4,2) = \frac{6132}{4^{10}} = 0.0058479309...$$