Three colors — Drawing marbles until one color is exhausted

probability

A bag contains three colors of marbles in known quantities. Marbles are drawn randomly one at a time until any color is exhausted. What is the probability a given color exhausts first?

For only two colors, the answer is intuitive — if a color occupies 1/nth of the bag, that is how often it will "survive". Simulating three colors, I'm not seeing the general pattern.

(The sim is sanity checked with {1,2,3}. Of the 60 combos of rggbbb, red exhausts first in 35 of them)


import random

red_out, green_out, blue_out = 0,0,0

runs = 100000

for i in range(0,runs):

red = 1
green = 2
blue = 3

while (red > 0 and green > 0 and blue > 0):
    rand = random.random()
    total = red + green + blue
    frac_red = red/total
    frac_green = green/total
    
    if (rand <= frac_red): red-=1
    elif (frac_red < rand <= frac_red + frac_green): green-=1
    else: blue-=1
   
    if (red == 0): red_out+=1
    elif (green == 0): green_out+=1
    elif (blue == 0): blue_out+=1

print("RED:",red_out/runs); print("GREEN:",green_out/runs);
print("BLUE:",blue_out/runs)

Best Answer

Assume we draw from the bag until the bag is empty. What's the probability that blue is last to be exhausted? We denote this event as $B_3$, ie. blue is the third color to be exhausted from the bag. Applying the same logic as the two color case, we get: $$P(B_{3}) = \frac{b}{r+g+b}$$

Let's assume we already know we are in a situation where blue is the longest survivor. What then would be the probability that green is the second to be exhausted? The second longest-survivor is either green or red, so for all intents and purposes, we can ignore blue. We get the conditional probability:

$$P(G_{2}|B_{3}) = \frac{g}{r+g}$$

From these we can get probability that "green is second to be exhausted and blue is third":

$$P(G_{2} \land B_{3}) =P(B_{3}) P(G_{2}|B_{3}) = \\ = \left(\frac{b}{r+g+b} \right) \left(\frac{g}{r+g} \right)$$

We may compute:

$$P(R_{1}) = P(G_{2} \land B_{3}) + P(B_{2} \land G_{3}) = \\ = \left(\frac{b}{r+g+b} \right) \left(\frac{g}{r+g} \right) + \left(\frac{g}{r+g+b}\right) \left(\frac{b}{r+b} \right) $$

Applying to $r = 1$, $g = 2$, $b = 3$, we get: $$ P(R_1) = \frac{2}{1+2+3}\;\frac{3}{1+3} + \frac{3}{1+2+3}\;\frac{2}{1+2} = \frac{7}{12} $$

Related Question