# How to distribute identical balls in different boxes?

600 identical balls must be randomly distributed into 6 numbered boxes. What is the probability of exactly 300 balls ending up in the first three boxes? Note that all balls must be distributed but boxes can be empty.

I think I have solved it but I don't know if it is right since the way I solved it looks wrong, but let me explain how I did it. So what we have here is combinations with repetitions, we have 600 to distribute in 6 different boxes and we can put as many balls as we want in Box 1 but the criteria we have is that exactly 300 should be in the first 3 boxes. Totally we have C(6+600-1,600-1). Step 2: How many ways can we divide 300 balls in the first 3 boxes, C(3+300-1, 300-1). In how many ways can we divide 300 balls in the last 3 boxes, C(3+300-1, 300-1). We use multiplication principle and then just divide favorable outcomes by the total number of outcomes ? Is it right?

– robjohn
Commented Oct 9, 2022 at 17:30
• What did you obtain for the total? Commented Oct 9, 2022 at 17:48
• You appear to be using Stars and Bars, but that doesn't seem like an appropriate method. Keep in mind that the patterns counted by that method are not equally probable. Hint: a binomial distribution is all you need here.
– lulu
Commented Oct 9, 2022 at 17:51
• Per the comment of @lulu, see Binomial Distribution, specifically $\displaystyle \binom{n}{k}p^kq^{(n-k)}.$ Commented Oct 9, 2022 at 19:12
• Per the last comment of @N.F.Taussig, and my last comment, since this is a Probability problem, rather than an enumeration problem, if you pretend that the balls are not identical, the answer to the Probability problem will not be changed. Commented Oct 9, 2022 at 19:26

I agree with lulu, user2661923 and N.F.Taussig that you can treat the balls as numbered and use the binomial distribution. Thus, the answer is $$\binom{600}{300}(\frac12)^{600} \approx 0.0325599$$

A Monte Carlo simulation (see python 3 code below) gives: $$0.03256$$

import random, math
successes=0
numtries=100000
for tries in range(numtries):
boxes=[0,0,0,0,0,0]
for boll in range(600):
boxes[random.randrange(6)]+=1
if(boxes[0]+boxes[1]+boxes[2] == 300):
successes+=1
print("Monte Carlo:", successes/numtries)
print("Exact:", math.comb(600,300)*0.5**600)

• Even if you are offering this as a simulation, you should provide what you get as output and offer a judgement on what it says about the answer of the Question you responded to. As you likely know, a Monte Carlo simulation will typically be run a number of times so that the results can be averaged in some way. You might also offer an opinion on whether with a comparable amount of work get an exact answer. Commented Oct 12, 2022 at 22:47