# What's the probability of tossing $r$ heads in a row before $s$ tails in a row?

I know that the probability of tossing $r$ heads in a row is eventually $1$, but how about tossing $r$ heads in a row before $s$ tails in a row? What's the easiest way to compute this probability? And what if the coin is biased, say, with probability $p$ showing a head?

## 2 Answers

Here is a Good & Unambiguous answer.

Read the first & fifth post:

http://www.sosmath.com/CBB/viewtopic.php?f=6&t=59864

Call $t=p^{r-1}$, $h=(1-p)^{s-1}$, and $A=[r\ \text{heads in a row before}\ s\ \text{tails in a row}]$.

Assume the first toss is a head. Then $A$ is equivalent to the event that $N$ is odd, where $N$ is the first $n$ such that $X_n=1$, where the sequence $(X_n)_{n\geqslant1}$ is independent with $\mathrm P(X_{2n-1}=1)=t$ and $\mathrm P(X_{2n}=1)=h$. In words, $X_n$ records whether the length of the $n$th row is at least $r$ or $s$, once started, or not. For every $n\geqslant0$, $\mathrm P(N=2n+1)=(1-t)^n(1-h)^nt$ hence $$\mathrm P(A\mid\text{first toss is a head})=\sum\limits_{n\geqslant0}(1-t)^n(1-h)^nt=\frac{t}{t+h-th}.$$ Likewise, if the first toss is a tail, $A$ is equivalent to the event that $M$ is even, where $M$ is the first $n$ such that $Y_n=1$, where the sequence $(Y_n)_{n\geqslant1}$ is independent with $\mathrm P(Y_{2n-1}=1)=h$ and $\mathrm P(Y_{2n}=1)=t$. For every $n\geqslant1$, $\mathrm P(M=2n)=(1-h)^{n}(1-t)^{n-1}t$ , hence $$\mathrm P(A\mid\text{first toss is a tail})=\sum\limits_{n\geqslant1}(1-h)^n(1-t)^{n-1}t=\frac{(1-h)t}{t+h-th}.$$ Finally, the first toss is a head with probability $p$ and a tail with probability $1-p$ hence $$\mathrm P(A)=\frac{pt+(1-p)(1-h)t}{t+h-ht}=\frac{p^{r-1}(1-(1-p)^s)}{p^{r-1}+(1-p)^{s-1}-p^{r-1}(1-p)^{s-1}}.$$ If $p=\frac12$, this is $$\mathrm P(A)=\frac{2^s-1}{2^r+2^s-2}.$$ Edit: A direct way to deduce $\mathrm P(A\mid\text{first toss is a tail})$ from $\mathrm P(A\mid\text{first toss is a head})$ is to note that these are probabilities of complementary events once one replaces $(t,h)$ by $(h,t)$.