Probability – Calculating Recurrence Formula for N Consecutive Heads on a Coin

conditional-expectationprobabilityself-study

I want to find the expected number of coin tosses to get $N$ heads in a row, where $p$ is the probability of getting a head in a single toss.

Let $F(N)$ be the expected number of tosses to get $N$ heads consecutively, so

$$F(N) = 1 + p F(N-1) + (1-p) F(N)$$

which gives

$$F(N) = 1/p + F(N-1)$$

With base condition : $F(1) = 1 + 1/p$

My logic is as follows:

if we get a head, in current toss we need to get N-1 more heads consecutively, but if we get a tail, we have to start over

This is what I thought, but is not correct. Can you please help me?

Best Answer

Let $T^{(k)}$ be the time it takes to see the first run of $k$ successes.

Let $X\sim\mathrm{Ber}(p)$ be independent of $T^{(k)}$ for every $k$. Then, $$ T^{(k)} = (T^{(k-1)}+1)\, X + (T^{(k-1)}+1+T^{(k)}) \, (1 - X) \, , $$ because, in words, if I see a success in the current trial, then the time to get $k$ consecutive successes is the time to get $k-1$ consecutive successes plus one (the current trial); but if I see a failure, the time to get $k$ consecutive successes is the time to get $k-1$ consecutive successes plus one (the current trial), plus itself, because the process restarted in distribution.

Defining $a_k=\mathrm{E}[T^{(k)}]$, we find the recurrence $$ a_k = (a_{k-1}+1)\,p + (a_{k-1}+1+a_k)\,(1-p) \, , $$ or $$ a_k = \frac{a_{k-1}}{p}+\frac{1}{p} \, . $$

Related Question