Someone I know recently shared the following exercise:
A bag contains exactly 15 marbles of which 3 are red, 5 are blue, and 7 are green. The marbles are chosen at random and removed one at a time from the bag until all of the marbles are removed. One color of marble is the first to have 0 remaining in the bag. What is the probability that this color is red?
After a bit of thinking, I defined a function $P_3$ that can be used to solve this exercise:
$$ P_3(n_r; n_b, n_g) := n_r \sum_{g=0}^{n_g-1} \sum_{b=0}^{n_b-1} \frac {(b + g + n_r - 1)! (n_b)_b (n_g)_g} {b! g! (n_b + n_g + n_r)_{b + g + n_r}}, $$
where $n_b,n_g,n_r$ are the number of blue, green, and red marbles respectively, and $(x)_y=\frac{x!}{(x-y)!}$ is the falling factorial (not the Pochhammer symbol). Evaluating $P_3(n_r=3;n_b=5,n_g=7)$ gives $\mathbf{0.525}$ or $\mathbf{\frac{21}{40}}$, which is the correct answer to the exercise.
Here's the reasoning behind the function definition:
We have a bag with $n_b$ blue marbles, $n_g$ green marbles, and $n_r$ red marbles. Consider an experiment where we take marbles from this bag without replacement, and stop when a color of marble is the first to have 0 left in the bag (could be blue, green, or red). The number of experiments where red reaches 0 first, given that $b$ blue marbles and $g$ green marbles were drawn, is $\frac {(b + g + n_r - 1)!} {b! g! (n_r-1)!}$, for $b<n_b$ and $g<n_g$. We're subtracting 1 from $n_r$ since the last marble drawn must be red. We then multiply this by $\frac {n_r! \left( n_b \right)_{b} \left( n_g \right)_{g}} {\left( n_b+n_g+n_r \right)_{b+g+n_r}}$, which is the probability of drawing $n_r$ red marbles, $b$ blues, and $g$ greens in a particular order. For the exercise, this fraction will look like $\frac {(3 \times 2 \times 1) (5 \times 4 \times \cdots) (7 \times 6 \times \cdots)} {15 \times 14 \times \cdots}$, depending on how many blue and green marbles are drawn. We then sum from $b=0$ to $n_b-1$ and from $g=0$ to $n_g-1$ to account for all possible values of $b$ and $g$ that allow for red to reach 0 first, and simplify.
With some algebra, it's possible to simplify $P_3$ into a closed-form rational function:
$$ P_3(n_r;n_b,n_g) = \frac {n_b n_g (2 n_r + n_b + n_g)} {(n_b + n_g + n_r) (n_b + n_r) (n_g + n_r)}. $$
I then considered generalizing this to any number of colors, which is completely beyond the exercise's scope, but I thought it would be fun.
Let $\{c_1,c_2,\dots,c_n\}$ be the set of all colors present in the bag, and let $n_i$ be the number of marbles of color $c_i$, where $i$ is an integer between $1$ and $n$ (inclusive). Without loss of generality, suppose we want to know the probability that the marble of color $c_1$ is the first to have $0$ left in the bag, if we're taking marbles without replacement. Then using the same reasoning to obtain $P_3$, the definition of $P_n$ is
$$ P_n(n_1;n_2,\cdots,n_n):=n_1 \sum_{i_2=0}^{n_2-1} \sum_{i_3=0}^{n_3-1} \cdots \sum_{i_n=0}^{n_n-1} \frac {(n_1 - 1 + i_2 + i_3 + \cdots + i_n)! (n_2)_{i_2} (n_3)_{i_3} \cdots (n_n)_{i_n} } {i_2! i_3! \cdots i_n! (n_1 + n_2 + \cdots + n_n)_{n_1+i_2+i_3+\cdots+i_n}}, $$
or written with sums and products,
$$ P_n(n_1;n_2,\cdots,n_n)=n_1 \sum_{i_2=0}^{n_2-1} \sum_{i_3=0}^{n_3-1} \cdots \sum_{i_n=0}^{n_n-1} \frac {\left(n_1 - 1 + \sum_{j=2}^{n} i_j\right)! \prod_{j=2}^{n} (n_j)_{i_j} } {\left( \prod_{j=2}^{n} i_j! \right) \left( \sum_{j=1}^{n} n_j \right) _ { n_1 + \sum_{j=2}^{n} i_j }}. $$
Without using falling factorials, we can write $P_n$ as
$$ P_n(n_1;n_2,\cdots,n_n)=n_1 \frac { \prod_{j=2}^{n} n_j! } { \left( \sum_{j=1}^{n} n_j \right)! } \sum_{i_2=0}^{n_2-1} \sum_{i_3=0}^{n_3-1} \cdots \sum_{i_n=0}^{n_n-1} \frac {\left(n_1 - 1 + \sum_{j=2}^{n} i_j\right)! \left( \sum_{j=2}^{n} \left( n_j - i_j \right) \right) !} {\prod_{j=2}^{n} (n_j - i_j)! i_j! }. $$
It's also possible to express $P_n$ using binomial coefficients:
$$ P_n(n_1;n_2,\cdots,n_n)=\frac {n_1} {\left ( \sum_{j=1}^{n} n_j \right)!} \sum_{i_2=0}^{n_2-1} \sum_{i_3=0}^{n_3-1} \cdots \sum_{i_n=0}^{n_n-1} \left( \left(n_1 - 1 + \sum_{j=2}^{n} i_j \right)! \left( \sum_{j=2}^{n} \left( n_j - i_j \right) \right)! \prod_{j=2}^{n} \binom {n_j} {i_j} \right). $$
I'm not sure how to keep simplifying from here. I'd like to know if there is a way to write $P_n$ using an integral or using special functions (in my opinion, special functions like $\mathrm{erf}$ and $ _aF_b$ are "closed form" in this context) instead of these iterated summations and products. (Basically, anything not containing $n-1$ iterated sums would be useful.) It looks kind of hypergeometric, but not exactly. I'd also be interested in approximations to $P_n$ as well.
(I tried being a little clever by seeing if we could get $P_4$ using $P_3$'s rational function form (meaning that I tried defining $P_4$ as $P_4(n_1;n_2,n_3,n_4) = \frac {n_2 n_3 n_4 (3 n_1 + n_2 + n_3 + n_4)} {(n_1 + n_2 + n_3 + n_4) (n_1 + n_2) (n_1 + n_3) (n_1 + n_4)}$) and see where I could go from there, but I didn't get the same results using the iterated summation, so this is wrong.)
Any help would be appreciated.
I think there's a much simpler approach. The probability that the last marble drawn is (red, blue, green) is $\left (\frac 15, \frac 13, \frac{7}{15} \right)$, respectively.
If you know that the last marble drawn is green, then the probability that the last non-green marble drawn is blue is $\frac 58$, so the conditional probability that red is the first color to deplete to $0$ is $\frac 58$.
If you know the last marble drawn is blue, then the probability that the last non-blue marble drawn is green is $\frac{7}{10}$, so the conditional probability that red is the first color to deplete to $0$ is $\frac{7}{10}$.
Putting these together, the probability that red is the first color to deplete to $0$ is $\frac 13 \cdot \frac {7}{10} + \frac{7}{15} \cdot \frac 58=\frac{21}{40}$.