[Math] Probability of drawing all red balls before any green ball

probability

Question:

Suppose that a box contains $r$ red balls, $g$ green balls,
and $b$ blue balls. Suppose also that balls are drawn from
the box one at a time, at random, without replacement.
What is the probability that all $r$ red balls will be obtained
before any green balls are obtained?

Solution(Partial):

I know this solution for $1$ red, $1$ green and $1$ blue balls:

$$\begin{array}{c|l|c}
\color{red}{red} & \color{green}{green} & \color{blue}{blue} \\
\hline \\
\color{blue}{blue} & \color{red}{red} & \color{green}{green} \\
\hline \\
\color{red}{red} & \color{green}{green} & \color{blue}{blue} \\\hline \\
\color{green}{green} & \color{red}{red} & \color{blue}{blue} \\\hline \\\color{green}{green} & \color{blue}{blue} & \color{red}{red} \\\hline \\ \color{blue}{blue} & \color{green}{green} & \color{red}{red} \\
\end{array}$$

This means,that there are $3$ outcomes for this event with the sample space of $6$.So, probability is $\frac{1}{2}$.

But I don't know how to generalize this.

Please help.Thank you.

Best Answer

To count the sequences of $r+b+g$ draws in which all of the red balls precede all of the green balls, note that they are obtained by starting with the sequence

$$\underbrace{RR\ldots RR}_r\underbrace{GG\ldots GG}_g$$

and inserting the $b$ blue balls arbitrarily into the sequence. This is a straightforward stars-and-bars problem; the link has both a formula and a pretty decent explanation of it, but if you have questions, leave a comment. Bear in mind that in any given sequence the $r$ red balls can actually be arranged in $r!$ orders, the blue balls in $b!$, and the green balls in $g!$, so that a given sequence of colors actually corresponds to $r!b!g!$ different sequences of balls drawn. However, since this is the same for each sequence of colors, it does no harm to count sequences of colors instead of sequences of balls.

Once you have that, you need only count the possible sequences of colors. You have to choose $r$ positions for the red balls, $b$ for the blue balls, ...