๐Ÿงฎ Brain Teaser

The Gambler's Fair Coin Sequence

You repeatedly flip a fair coin. What is the expected number of flips until the pattern HH first appears? What about until HT first appears?

Both patterns require seeing two specific consecutive outcomes โ€” yet their expected waiting times are different. Find both expected values and explain intuitively why they differ.

Markov chainsexpected valuecoin flippingpattern waiting timestate equations

Answer: HH vs HT: Waiting Times for Coin Patterns

Key Idea / Intuition

At first glance, HH and HT seem symmetric โ€” each is a sequence of two fair-coin outcomes. But they behave very differently because of what happens when a "near-miss" occurs. If you're waiting for HH and you see HT, you've wasted both flips. But if you're waiting for HT and you see HH, the second H can still serve as the start of a future HT. This asymmetry in "overlap structure" makes HH harder to achieve, giving it a longer expected waiting time.


Formal Proof / Solution

Expected time to HH

Let EE = expected number of flips to see HH from a fresh start.
Let EHE_H = expected additional flips to see HH, given the last flip was H.

Setting up equations:

From a fresh start, flip once:

  • With prob 12\tfrac{1}{2}, get T โ†’ back to fresh start. Cost: 1 flip.
  • With prob 12\tfrac{1}{2}, get H โ†’ now in state EHE_H. Cost: 1 flip.

E=1+12E+12EHE = 1 + \tfrac{1}{2} E + \tfrac{1}{2} E_H

From state EHE_H (last flip was H), flip again:

  • With prob 12\tfrac{1}{2}, get H โ†’ done! Cost: 1 flip.
  • With prob 12\tfrac{1}{2}, get T โ†’ back to fresh start. Cost: 1 flip.

EH=1+12(0)+12E=1+12EE_H = 1 + \tfrac{1}{2}(0) + \tfrac{1}{2} E = 1 + \tfrac{1}{2} E

Substituting into the first equation:

E=1+12E+12โ€‰โฃ(1+12E)=2+34EE = 1 + \tfrac{1}{2}E + \tfrac{1}{2}\!\left(1 + \tfrac{1}{2}E\right) = 2 + \tfrac{3}{4}E

14E=2โ€…โ€ŠโŸนโ€…โ€ŠEHH=6\tfrac{1}{4}E = 2 \implies \boxed{E_{HH} = 6}


Expected time to HT

Let FF = expected flips to HT from fresh start.
Let FHF_H = expected additional flips, given last flip was H.

From a fresh start:

  • With prob 12\tfrac{1}{2}, get T โ†’ back to fresh start. Cost: 1 flip.
  • With prob 12\tfrac{1}{2}, get H โ†’ state FHF_H. Cost: 1 flip.

F=1+12F+12FHF = 1 + \tfrac{1}{2}F + \tfrac{1}{2}F_H

From state FHF_H (last flip was H), flip again:

  • With prob 12\tfrac{1}{2}, get T โ†’ done! Cost: 1 flip.
  • With prob 12\tfrac{1}{2}, get H โ†’ stay in FHF_H (the new H can still start HT). Cost: 1 flip.

FH=1+12(0)+12FHF_H = 1 + \tfrac{1}{2}(0) + \tfrac{1}{2}F_H

12FH=1โ€…โ€ŠโŸนโ€…โ€ŠFH=2\tfrac{1}{2}F_H = 1 \implies F_H = 2

Substituting back:

F=1+12F+12(2)=2+12FF = 1 + \tfrac{1}{2}F + \tfrac{1}{2}(2) = 2 + \tfrac{1}{2}F

12F=2โ€…โ€ŠโŸนโ€…โ€ŠEHT=4\tfrac{1}{2}F = 2 \implies \boxed{E_{HT} = 4}


Why the difference? (Intuition recap)

| Pattern | Near-miss behavior | Expected time | |---------|-------------------|---------------| | HH | Getting HT resets you completely | 6 | | HT | Getting HH keeps you in a "H seen" state | 4 |

For HH: a failure (getting T after H) wastes everything.
For HT: a "false start" (getting HH) is not fully wasted โ€” the second H still counts as a potential head toward HT.

This is an instance of the general theory of pattern waiting times, where the overlap structure of the pattern determines how quickly it appears. HH has a self-overlap (its first H is also a valid start of HH), which paradoxically hurts it, because each near-miss costs more.

Source: Fifty Challenging Problems in Probability with Solutions (Frederick Mosteller) โ€” related folklore; pattern waiting time is classical probability

Type: ProbabilitySource: Fifty Challenging Problems in Probability with Solutions (Frederick Mosteller) โ€” related folklore; pattern waiting time is classical probabilityEdit on GitHub โ†—