3
$\begingroup$

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)

$\endgroup$
3
  • $\begingroup$ I was engaged in watching the Italian Open, so the brief answer, I have expanded it for greater conceptual clarity. Cheers ! $\;\;$ :) $\endgroup$ Commented May 21, 2023 at 7:57
  • $\begingroup$ Thanks to both of you. Looking at it backwards in terms of survival makes perfect sense, since it can then be treated like the two-color problem. Having the simulation available just gave me tunnel vision. $\endgroup$
    – Calibur
    Commented May 21, 2023 at 14:19
  • $\begingroup$ Glad to have been of help ! $\;\;$ :) $\endgroup$ Commented May 21, 2023 at 14:23

2 Answers 2

5
$\begingroup$

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} $$

$\endgroup$
3
$\begingroup$
  • To get the desired result, the three colors must survive longest either in the order $BGR$ or $GBR$.

  • We already know how to compute survival probability for two colors, eg with $2B,4$ "others" in the given example,
    P($B$ survives max) = P($B$ drawn last) =P($B$ put first)$=\frac26$

  • The punchline is that having computed the survival probability of blue, to compute the survival probability of the next color, we just imagine that blue marbles have vanished from the row, so again we have only two colors to deal with ! And we can iterate this process, always dealing with only two colors at a time, for any number of colors.

Thus P($B$ survives longest followed by $G$) $=\frac36\frac23 =\frac13$

and ($G$ survives longest followed by $B$) $= \frac26\frac34 = \frac14$

Finally, P(red is first to "die") $= \frac13+\frac14 = \frac7{12} \equiv \frac{35}{60}$ of your simulation

$\endgroup$
1
  • $\begingroup$ I wonder why I couldn't see user3257842 answer while I was posting mine. Anyway, that answer is explained in more detail than mine, so I am upvoting it. $\endgroup$ Commented May 20, 2023 at 20:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .