Probability of drawing a run of a specific color from an urn with two colors of balls

Solution 1:

Suppose that we have $w$ white balls and $b$ black balls, and that they are placed in a random order. Define the indices with black balls to be $1\leq i_1<i_2<\cdots < i_b\leq w+b$. We define the gaps between the black balls to be $$g_1=i_1, \quad g_j=i_j-i_{j-1} \mbox{ for }2\leq j\leq b,\quad \mbox{ and }\ g_{b+1}=(b+w+1)-i_b.$$

Note that these gaps form a composition of the integer $b+w+1$ into $b+1$ parts, and that there is a one-to-one correspondence between random ordering of the colors and such compositions.

For example, if $w=3$ and $b=2$ then the order $BWWBW$ corresponds to the composition $1+3+2$ of $6$ into $3$ parts. In general, $g_1+g_2+\cdots +g_{b+1}=b+w+1.$

Now those orders where the runs of white balls all have size less than $m$ are exactly those where the black gaps are at most $m$. But we can count these with the same formula that tells us how many ways we can roll $b+1$ dice with $m$ sides and get a total of $b+w+1$, i.e.,

$$S:=\sum_{j=0}^{\lfloor w/m\rfloor} (-1)^j {b+1\choose j}{w+b-jm\choose b}.$$

The required probability of at least one run of $m$ or more consecutive white balls is $$P=1-{S\over {b+w\choose b}}.$$

For $w=128$, $b=288$, and $m=10$ this gives $P=.001708427151$.