Coin pattern waiting timesAbout 6 min · Untimed

Discover

The progress you keep

The expected wait for a coin pattern depends on how the pattern overlaps with itself. A failed attempt at HT ending in H preserves a live prefix, giving E[HT] = 4, but a failed attempt at HH ending in T destroys all progress, stretching E[HH] to 6. Longer runs compound the effect: E[HHH] = 14, while the non-overlapping THH needs only 8 flips on average.

Words you need

State
Where the process is right now, which is all that matters for what happens next.
First-step analysis
Write the answer from a state as one step plus the average answer from wherever that step lands, then solve the equations.
Why it works

First-step equations on the longest-matched-prefix states capture exactly how much progress each failure preserves.

E[HT] = 4, E[HH] = 6, E[HHH] = 14, E[THH] = 8

Spot it: You need expected flips until a coin pattern of length 2 or 3 appears.

Technique reference and sources

Self-overlap means a nonempty proper prefix of the pattern equals a suffix of the completed pattern. HT has no such border, HH has border H, HTH has border H, and HHH has borders H and HH. Waiting times come from the transition equations on longest-matched-prefix states (equivalently the border sum), not from a shorter or longer heuristic.

When this method fits

  • You need expected flips until a coin pattern of length 2 or 3 appears.
  • An interviewer asks why HH takes longer than HT.
  • You must compare pattern waits (HHH vs THH, HTH vs HHT).
  • Overlapping prefixes suggest the wait will exceed 2^length.
  1. Name prefix states. State 0 (no progress), state H (last flip starts the pattern), and so on up to the full pattern.
  2. Write one equation per state. Each equation adds 1 for the flip, then branches on H and T to the preserved-progress state.
  3. Track failure progress. From state H waiting for HT, flipping H keeps state H; waiting for HH, flipping T drops to state 0.
  4. Solve from the deepest state. Write the coupled equations, collect self-loop terms, and eliminate unknowns. Back-substitution works after the dependencies have been resolved.
Length-2 waits: Non-overlapping HT and TH take 4 flips; self-overlapping HH and TT take 6 flips.
  • E[HT] = 4 with E_H = 2
  • E[HH] = 6 with E_H = 4
Length-3 waits: No self-overlap (HHT, HTT, THH, TTH): 8. One short border (HTH, THT): 10. Full overlap (HHH, TTT): 14.
  • E[THH] = 8
  • E[HTH] = 10
  • E[HHH] = 14
Border-sum waiting-time formula: For a fair coin, sum 2^j over prefix lengths j that are also suffix lengths, including the full pattern. Use it when only the unconditional expected wait is requested; it loses for conditional waits, competing patterns, or a derivation using states.
  • HT: 2^2 = 4
  • HH: 2 + 4 = 6
  • THH: 8 = 8
  • HTH: 2 + 8 = 10
  • HHH: 2 + 4 + 8 = 14

Common traps

Assuming every length-2 pattern takes 4 flips because each has probability 1/4 per window. Window probability ignores overlap. HT failures can preserve a useful H, while HH failures destroy all progress, so E[HH] = 6 exceeds E[HT] = 4. Only patterns with no self-overlap border match the naive 4.

Restarting from state 0 after every failed flip regardless of pattern. Match the flipped suffix against the pattern prefix. Waiting for THH, flipping T then H keeps state TH (two flips of progress), while flipping T then T keeps only state T. Preserved progress depends on the exact suffix.

Quoting E[HHH] = 8 by cubing the single-flip odds. 2^3 = 8 only prices patterns with no self-overlap border. Self-overlap describes borders of the completed pattern. For runs of heads, a tail destroys all partial progress; the state equations give 6 for HH and 14 for HHH.

Another example: Expected flips to HHH
  1. Deepest state: E_HH = 1 + 0.5 * 0 + 0.5 * E_0 = 1 + 0.5 * E_0 (T after HH keeps no prefix of HHH)
  2. Middle state: E_H = 1 + 0.5 * E_HH + 0.5 * E_0 = 1 + 0.5 * (1 + 0.5 * E_0) + 0.5 * E_0 = 1.5 + 0.75 * E_0
  3. Scratch: E_0 = 2 + E_H = 2 + 1.5 + 0.75 * E_0 = 3.5 + 0.75 * E_0, so 0.25 * E_0 = 3.5 and E_0 = 14

Source notes

These explanations and questions are written for QuantArc. Links show the underlying mathematics and learning design.

Harvard Stat 110: Probability (Joe Blitzstein)
Free course site with videos and the open companion book Introduction to Probability; the topic spine for counting, Bayes, and linearity. Lesson examples and questions are original.

Grinstead and Snell, Introduction to Probability (free PDF)
Free textbook PDF confirmed live: counting methods, poker-style dealing models, and the random-walk chapter behind gambler's ruin and first-step equations. Lesson examples and questions are original.

IES: Organizing Instruction and Study to Improve Student Learning
Supports worked examples, retrieval, explanations and spaced study. Does not establish QuantArc's exact lesson length, mastery threshold or review intervals.