Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

say, I have 3 red balls, 4 yellow balls, 5 blue balls. totally 12 balls

now I randomly arrange the balls, a1...a12

a good layout is such: a1 = a12 or a1 = a11 or a2 = a12 (= means same color)

what's the probability of gaining a good layout?

I believe it is somewhat 66%=0.2879*3-0.06818*2-0.7273+0.01212 but my program (10000 random runs) gives 44%...


My Maths is correct, my program has a bug..., now corrected.

share|cite|improve this question
What do you get for just the chance that a1=a12? – Ross Millikan Aug 23 '11 at 16:06
my maths told me it's 28.8% – colinfang Aug 23 '11 at 16:07
I agree with that. Then .06818 is the chance of a1=a11=a12, which I also agree with. Maybe you could check your program for the individual contributions. – Ross Millikan Aug 23 '11 at 17:36
up vote 6 down vote accepted

There are ${12\choose 2}=66$ ways to choose a pair of balls, and ${3\choose 2}+{4\choose 2}+{5\choose 2}=19$ ways for them to have the same color. Thus, $$\mathbb{P}(a_1=a_{11})=\mathbb{P}(a_1=a_{12})=\mathbb{P}(a_2=a_{12})={19\over 66}.$$

Similarly, we have $$\mathbb{P}(a_1=a_{11}=a_{12})=\mathbb{P}(a_1=a_2=a_{12})={3\over 44},$$ and $$\mathbb{P}([a_1=a_{11}]\cap [a_2=a_{12}]) = {14\over 165}.$$

Finally, $$\mathbb{P}([a_1=a_{11}=a_2=a_{12}]) = {2\over 165}.$$

By inclusion-exclusion, the chance of getting a good configuration is $$3\cdot {19\over66}-2\cdot {3\over44}-{14\over 165}+{2\over 165}={36 \over55}=.65454.$$

share|cite|improve this answer

your simulation program might be wrong. My simulation shows that the probality on 10000 round is 65.6%.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.