# Probability with changing number of marbles

Given a bag containing 20 marbles of 5 different colors in this configuration:

8x Blue
6x Red
3x Green
2x White
1x Black

How would you determine the probability of picking a marble of a specific color given these rules:

• 4 marbles are picked one after the other from the bag
• Once a marble is picked, all remaining marbles of the same color are removed from the bag

So as an example of how the process might happen:

1. From the initial 20 marbles, the first one that is picked is blue
2. All the remaining blue marbles are removed, leaving 12 marbles
3. The next marble that is picked is black
4. There aren't any black marbles left, so 11 marbles remain
5. The next marble that is picked is red
6. All the remaining red marbles are removed, leaving 5 marbles remaining
7. The last marble that is picked is white

So a blue, black, red and white marble was picked, and only the green marbles remained untouched.

In essence the question is given the initial configuration and the rules, what are the probabilities for each of the colors of being picked. So the probability of 1 of the 4 marbles being Blue is x and the probability of 1 of the 4 marbles being Red is y.

• The details of the process are easy to understand, but it is unclear what the actual question is. "Determine the probability of picking a marble of a specific color" sounds straightforward, but you will actually be picking four marbles of different colors. What outcome(s) are you asking for the probability of? – hardmath Jun 26 '15 at 19:54
• There are enough complexities here that a brute-force tree diagram covering all four choices might be best. This tree will have only $120$ branches so although large it is very doable. – Rory Daulton Jun 26 '15 at 19:56
• @hardmath I tried to clarify the question, hopefully that explains it. – TheTexan Jun 26 '15 at 20:00
• Yes, it is clear and sensible. Note that since there are four colors chosen in every procedure, you are essentially asking for the probability complementary to the color of the remaining marbles, those not chosen. I don't know if there is a better way than to create the decision tree and track the probabilities of outcomes through that. – hardmath Jun 27 '15 at 0:05
• @RoryDaulton: There are only thirty "states" for which to compute intermediate and final probabilities (after the initial state of marbles), because of the binomial enumeration of subsets at work. But we do have to compute your branches between states and accumulate the probabilities accordingly. – hardmath Jun 27 '15 at 0:57

This can be done with the inclusion-exclusion principle. In order for a particular color marble to be drawn, it must be drawn before at least one of the other colors. So first we sum the 4 probabilities that it occurs before each one. Then we subtract the sum of the ${4 \choose 2}$ probabilities that it occurs before each pair of colors. Then we add back the sum of the ${4 \choose 3}$ probabilities that it occurs before each combination of 3 colors. Finally, we subtract the probability that it occurs before all 4 of the other colors. The probability that a color is drawn before a set of other colors is simply the ratio of the number of marbles of that color to the number of marbles in the set of colors.

Let $N_1,N_2,N_3,N_4,N_5$ be the number of marbles for colors $C_1,C_2,C_3,C_4,C_5$ to be selected. For example, the probability that $C_1$ is selected is

$P(C_1) = N_1/(N_1+N_2) + N_1/(N_1+N_3) + N_1/(N_1+N_4) + N_1/(N_1+N_5) -$

$[N_1/(N_1+N_2+N_3) + N_1/(N_1+N_2+N_4) + N_1/(N_1+N_2+N_5) + N_1/(N_1+N_3+N_4) + N_1/(N_1+N_3+N_5) + N_1/(N_1+N_4+N_5)] +$

$N_1/(N_1+N_3+N_4+N_5) + N_1/(N_1+N_2+N_4+N_5) + N_1/(N_1+N_2+N_3+N_5) +$
$N_1/(N_1+N_2+N_3+N_4) -$

$N_1/(N_1+N_2+N_3+N_4+N_5)$

These are the results I got by evaluating the above formula for blue, red, green, white, black respectively.

 0.981858492384808 0.964382547277284 0.864940632123295 0.751062619870669
 0.437755708343944

• At least one of us is wrong, I wonder who (not sure I'm right to be honest, it's quite a tricky question). – barak manos Jun 27 '15 at 7:38
• @barak manos My result matches simulation. Simulated numbers: 0.981765752211696 0.964612865057163 0.865029737417429 0.750064646559628  0.438523080780774 – BruceZ Jun 27 '15 at 7:53
• I'll wait to see other comments here (on your answer and on mine). – barak manos Jun 27 '15 at 8:13
• I'm not sure whether or not your answer is correct, but the comment above (the one which you just removed) seems flawed: "On the first draw, each marble has the same probability" - yes, but not each color. If you have based your simulation on this, then I think it could be wrong. – barak manos Jun 27 '15 at 11:16
• @barak manos That comment was about your answer and I moved it. Neither my simulation nor my exact answer assumes this. – BruceZ Jun 27 '15 at 11:21

Running a simulation with 100,000,000 epochs shows that the probabilities should be close to:

BLUE:  0.98187599
RED:   0.9644007
GREEN: 0.86490873
WHITE: 0.75109474
BLACK: 0.43771984


Source available on GitHub