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

I am looking for a way on how to think about a probability problem. It feels like there's a way how to simplify the task.

So, here's example of the problem:

From a pool of $15$ balls ($1$ red, $2$ blue, $3$ green, $4$ yellow and $5$ black) a set of $5$ balls, at random, is selected and put in a bag. We don't know which $5$ balls are there.

Now, $2$ balls are at random picked from this set of $5$ balls, observed and put back with the other $3$.

Let's say we saw a blue and a yellow ball. Now i'd like to calculate probability of picking specific set of two balls (there are $14$ such sets).

One obvious approach I see is to list all the possible sets of $5$ balls what could be drawn from the initial pool of $15$ balls (there are $71$ such set), each with certain probability being drawn, $P(i)$; filter it to leave only those sets that contain at least one blue and one yellow ball (there are $25$ such sets), and then calculate the probabilities for each of the $14$ two-ball sets for each of those $25$ five-ball sets, weighing (multiplying) them by $P(i)$ and summing them up in $14$ sums.

The question I'd like to find out, is if there is simpler way to find the result avoiding so many iterations over specific sets.

Maybe there's some smart way how to think about those unseen $3$ balls in the bag, that would let me avoid iterating over the $25$ sets of $5$ balls that contain a blue and a yellow ball.

share|cite|improve this question
Where are you getting these numbers $14$ and $71$ from? – Ataraxia Aug 10 '13 at 12:42
Since we know nothing about the 5 balls the fact that we pick 5 balls without looking then pick two balls and we only pick once the fact that we pick twice is not relevant. The problem then becomes one of picking at random the two blue balls from the set of 15 – Warren Hill Aug 10 '13 at 12:44
@Warren Hill : The fact that we see a blue and a yellow ball has some information to it, you can't just ignore it. For instance, if on the first pick you put $5$ balls in the bag, then looked at $3$ of them (turned out red blue blue), then on the next pick the probability of picking out $3$ yellow balls would be zero. (I changed the numbers a bit to get a zero probability ; in general it still has an influence but maybe not this much drastical). – Patrick Da Silva Aug 10 '13 at 12:51
It's something like doing a sampling estimation of a population, but you sampled too many information, so to understand a little bit better your sample without checking all of it, you sample the sample ; it gives you information about what's inside because you sample the sample in a random way. – Patrick Da Silva Aug 10 '13 at 13:02
@PatrickDaSilva: Sorry your correct I missed that point – Warren Hill Aug 10 '13 at 13:27
up vote 2 down vote accepted

Doing the problem assuming you saw a blue and yellow ball is easier than the general setting, in the sense that each case of color you see can be done with the same technique but the general pattern could be a bit ugly ; you would have to do them one by one (but of course after you understand the first one the other ones would be done similarly).

So you took $5$ balls out of $15$ and two of those $5$ balls are one blue and one yellow. You need to understand what's the probability distribution of the other three balls now. You also need to incorporate the info that you picked the two balls at random ; it is more likely to pick a blue and a yellow ball to look at if there is $2$ blue balls and $3$ yellow in the bag than otherwise, for instance.

So say you want to compute the probability of picking a blue ball and a red ball in the second try. You need to look at all possible cases which make that happen with non-zero probability : there must be a red ball in the bag for that to happen, so the two cases would be $1$ blue ball inside or $2$.

First case ; what is the probability that there is one red ball and one blue ball in the bag (precisely) assuming you picked one blue and one yellow after that?

$$ \mathbb P(1 R + 1 B \, | \, 1B + 1Y \text{ were picked } ) = \frac{\mathbb P( \{ 1R + 1B \} \cap \{1B + 1Y \text{ are picked } \})}{ \mathbb P(\{1B+1Y \} ) }. $$ So the denominator is easy to compute ; the fact that you picked $5$ balls first then $2$ out of those $5$ is the same thing as just picking $2$ balls out of $15$ if we don't care about what's in the bag, but only about what two balls we pick ; so the probability to compute is the number of ways to pick $1$ blue ball out of two and $1$ yellow ball out of $4$. There are different ways to compute this. One of them is this : either you pick the blue first and the yellow second, or the opposite ; this accounts for all cases. You divide through by $2$ because you don't care about the order in which the balls appear, so you don't want to double count. So $$ \mathbb P( \{ 1B + 1Y \} ) = \frac{ \binom 21 \binom 41 + \binom 41 \binom 21 }{2\binom {15}2 } = \frac{16}{\binom {15}2} = \frac{32}{15 \cdot 14} = \frac{16}{105}. $$ For the numerator, we should rewrite this as "$1R+1B+nY$ with $n \in \{1,2,3\}$" which gives us three cases to add up. Again, computing what happens at each step will give you probabilities. (At this point I'm tired of the numbers.)

You do the same for the $1R+2B$ case and when you both have them, in each case you compute the probability of pulling out a red ball and a blue ball assuming you know what's in the bag of $5$ balls ; add things up and you'll have your answer.

Hope that helps,

share|cite|improve this answer
Thanks. I am looking for a general solution (I'm writing a Python class for this), but your explanation gives me some hints how to decrease the total number of different probabilities to calculate. – Passiday Aug 10 '13 at 18:41
@Passiday. Whew. Why on earth would you wanna do that? It looks very painful computationally ; plenty, plenty of cases to write down. – Patrick Da Silva Aug 10 '13 at 19:10
I am developing a board game where there are several types of cards, each of certain quantity. I want to calculate the probabilities in order to tweak the game rules so that the game is balanced. And then I want to write AI for this game and let those AIs play thousands of games to see whether the statistics show balanced gameplay. If you are interested to see the class, I can share it with you. Not opening to public yet, while in development. – Passiday Aug 10 '13 at 20:12
@Passiday : I haven't done games before, so I don't know how people usually get around those computations in the code, but the only way I see it right now is to just do a tree of ifs and elseifs of all the possible cases, and that leaves you with plenty of writing. There is probably a way around, but it would deserve some major thinking. Maybe you can do some loops and figure it out. Will there be precisely $1$, $2$ ... $5$ red/blue/,../black "balls" in your game? – Patrick Da Silva Aug 11 '13 at 12:14
in my particular case there's some speculative betting involved. Some information about the pool is know, some not. In the game there are no balls involved, but cards. I refer to coloured balls in my post in order to generalize. In my game there are cards of different types but similar back sides. – Passiday Aug 11 '13 at 17:16

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.