# Probability of picking specific balls

Suppose I have $20$ red balls in one box and $20$ blue balls in another box. There $12$ red balls and $7$ blue balls have stars on them.

I randomly take out one red ball and one blue ball at each time, don't put them back, and repeat this $10$ times.

What is the probability that I get one red ball with stars and one blue ball with stars for at least $5$ times?

-

## migrated from stackoverflow.comOct 10 '13 at 19:37

This question came from our site for professional and enthusiast programmers.

Exactly $5$ times, or at least $5$ times? Either will be a messy calculation. –  Ross Millikan Oct 10 '13 at 19:41
You mean get them simultaneously or a total of five of each at the end? –  stevemarvell Oct 10 '13 at 20:22
The event that we are finding the probability of is not specified sufficiently clearly. –  André Nicolas Oct 10 '13 at 20:26
This is my understanding of the question. There are 10 events. At each event you pick one red and one blue, and discard both. An event is "good" if both balls have stars. If we try 10 times, we can expect between 0 and 7 "good" events. What is the probability that there will be exactly five "good" events out of 10. –  osa Oct 10 '13 at 20:30
Sorry about the confusion, I mean "at least 5 times". If we can figure out "exact 5 times", we can work out "at least 5 times" as well. –  Wen Oct 10 '13 at 21:28

## This is my understanding of the question. There are 10 events. At each event you pick one red and one blue, and discard both. An event is "good" if both balls have stars. If we try 10 times, we can expect between 0 and 7 "good" events. What is the probability that there will be exactly five "good" events out of 10.

The balls are essentially grouped in pairs, blue and red ones, and at each point we are picking every pair. There can be 5, 6, or 7 star-star pairs, and we want to know if we can pick exactly one such.

The probability of there being exactly 7 star-star pairs is P_7 = C(12, 7) / C(20, 7).

The probability of there being exactly 6 star-star pairs is P_6 = 7 * (20-12) * C(12, 6) / C(20, 7).

The probability of there being exactly 5 star-star pairs is P_5 = C(7, 2) * C(20-12, 2) * C(12, 5) / C(20, 7).

The probability of us picking exactly 5 such pairs during 10 trials, when there are 20 pairs total, is P_5 * C(15, 5) / C(20, 10) + P_6 * C(6, 5) * C(14, 5) / C(20, 10) + P_7 * C(7, 5) * C(13, 5) / C(20, 10).

Happy multiplying!

-
But there might not be any star pairs at all. All the starred blue ones could be paired with unstarred red ones. –  Ross Millikan Oct 10 '13 at 21:09
Your understanding is right except I just changed my question to look for the probability of AT LEAST five "good" events. Your answer is confusing me, I need to think it through. –  Wen Oct 10 '13 at 21:13
I have a few mistakes, actually. Fixed –  osa Oct 11 '13 at 3:05
I may have a few more.But I hope you get the idea. –  osa Oct 11 '13 at 3:16

Here's my thoughts, but it might be wrong:

I. Solve the probability of getting one red ball with stars and one blue ball with stars for exact 5 times.

1.1 Number of all possible ways of selecting 10 pairs of red/blue balls are C(20,10)*C(20,10).

1.2 Number of ways to select 5 red-star balls is P_5r = C(12,5)*C(20-12,5)

1.3 Number of ways to select 5 blue-star balls is P_5b = C(7,5)*C(20-7,5)

1.4 Number of ways to select 5 pairs of red/blue balls with at least one ball has star in each pair:
P_5r*P_5b -----anything wrong in this step?

1.5 Number of ways to select 5 pairs of red/blue balls with only one ball has star in each pair: P_5r*C(20-7,10)+C(20-12,5)*P_5b

1.6 Number of ways to select 5 pairs of red-star/blue-star balls is P_5r*P_5b - P_5r*C(20-7,10) - C(20-12,5)*P_5b

The probability of getting exact 5 pairs of red-star/blue-star balls is [P_5r*P_5b - P_5r*C(20-7,10) + C(20-12,5)*P_5b]/[C(20,10)*C(20,10)]

II. To get solution for "at least 5 times", just use 1 - probability of exact 0 time - probability of exact 1 time ... probability of exact 4 time

-