# Expected number of coin flips to see $3$ heads

You toss a coin until you see $$3$$ (not necessarily consecutive heads). What's the expected number of coin tosses you make?

I tried a lot of things, and I've seen the solution for three consecutive heads, but I'm not so sure how to do it if they are non-consecutive.

With probability $$1/8$$, we stop after the first three coin tosses (if we get HHH).

With probability $$3/16$$, we will terminate after the first four coin tosses (we can get THHH, HTHH, HHTH).

It gets really messy for the rest of them, and so I don't think this approach is quite correct. Can anyone please help me solve this problem?

• Consecutive is a lot harder than this...Just show inductively that the expected number of tosses needed to see $n$ $H's$ is $n$ times the expected number it takes to see $1$. – lulu Oct 2 '19 at 13:53
• Oh. So it's just $3 \cdot 2 = 6$ ? – user709945 Oct 2 '19 at 14:00
• Yep, that's all it is. – lulu Oct 2 '19 at 14:06
• Can you write it explictly , please @lulu – Aqua Oct 2 '19 at 14:09
• @Aqua Let $E_n$ be the expected time it takes to see exactly $n$ Heads. Then we have the recursion: $E_n=E_{n-1}+E_1$. Why? Well, to see $n$, you need to first see $n-1$, which you expect to take $E_{n-1}$ trials, and then you need to swee one more. Easy to show, inductively, that this implies $E_n=n\times E_1$. – lulu Oct 2 '19 at 16:14

No need for infinite sums here, the answer is just $$3\times E_1=6$$. More broadly, the expected number for $$n$$ Heads is $$2n$$.

To see this, let $$E_n$$ be the expected number of tosses for $$n$$ Heads. We note that, to see $$n$$ Heads requires that you first see $$n-1$$, which you expect to take $$E_{n-1}$$ tosses. Then you need to see one more, which you expect to take $$E_1$$ tosses. Thus we have the recursion $$E_n=E_{n-1}+E_1$$

It follows, inductively, that $$E_n=n\times E_1$$

Since $$E_1=2$$ the claim follows.

For completeness, here is a proof that $$E_1=2$$:

Consider the first toss. Either it is $$H$$ or $$T$$. If it is $$H$$, you stop. If it is $$T$$ you restart (but you've added $$1$$ to the count). Thus $$E_1=\frac 12\times 1+\frac 12\times (E_1+1)\implies E_1=2$$

May be worth remarking that this gives another approach to the original question. Say we want to compute $$E_n$$. Then we consider one toss. Either it is $$H$$, in which case you want $$E_{n-1}+1$$ or it is $$T$$ in which case you want $$E_n+1$$. Thus $$E_n=\frac 12\times (E_{n-1}+1)+\frac 12\times (E_n+1)\implies E_n=E_{n-1}+2$$

• Still you need an infinite sums else how would one calculate $E_1$? – Aqua Oct 2 '19 at 16:55
• @Aqua $E_1$ is easy to compute, I'll add it to my post. – lulu Oct 2 '19 at 17:05
• @lulu Nice answer. But it doesn´t seem that the approach is much easier than calculating the expected value by sum. – callculus Oct 2 '19 at 17:52
• @callculus This method calculates the value for all $n$ simultaneously...but, more importantly, recursive methods work even when series don't (or at least, when series are badly impractical). That's the basis behind, say Markov theory...in which some process moves between known states with known probabilities. – lulu Oct 2 '19 at 17:56
• @lulu Sure the calculation is much easier. But it might be the problem (for the OP) to understand why the equations look like this. It looks easy at the first view but to understand it really is another thing. – callculus Oct 2 '19 at 18:00

Hint: After $$n-1$$ tosses we need to see $$2$$ heads and $$n-1-2=n-3$$ tails.

The probability for that is $$\binom{n-1}{2}\cdot 0.5^2\cdot 0.5^{n-3}$$. The last toss must be head. Thus the probability to get 3 heads after n tosses is

$$P(X=3)=\binom{n-1}{2}\cdot 0.5^2\cdot 0.5^{n-3}\cdot 0.5=\binom{n-1}{2}\cdot 0.5^n$$

Now calculate the expected value.

$$\mathbb E(X)=\sum_{n=3}^{\infty} n\cdot \binom{n-1}{2}\cdot 0.5^n$$

Remark

If you have problems to calculate the sum see the answer here $$(k=3)$$ from Arash.

Hint: Assume you get 3 heads in k turns , at last you always get head and in k-1 turns some where you get 2 heads. Expectation is

$$\sum_{k=3}^{\infty}\binom{k-1}{2}.{1 \over 2^k} .k$$