Probability & Statistics

Waiting for HTH

Flip a fair coin until the pattern HTH first appears. How many flips should you expect to make?

solvedmedium1 min

You flip a fair coin until the pattern HTH appears as three consecutive tosses. What is the expected number of flips?

Reveal solutionHide solution

#States of progress

Track the longest tail of the tosses so far that starts HTH. The states are start, HH, HTHT, and the finished HTHHTH. Let aa, bb, cc be the expected flips still needed from start, from HH, and from HTHT.

#Mismatches and the reset

From start, a head advances to HH and a tail holds. From HH, another head keeps you at HH, since the fresh head is itself a new start of the pattern, while a tail advances to HTHT. From HTHT, a head finishes, but a tail resets all the way to start, since HTT shares nothing with the start of HTH.

a=1+12b+12a,b=1+12b+12c,c=1+120+12a.(1)a = 1 + \tfrac{1}{2}b + \tfrac{1}{2}a, \qquad b = 1 + \tfrac{1}{2}b + \tfrac{1}{2}c, \qquad c = 1 + \tfrac{1}{2}\cdot 0 + \tfrac{1}{2}a. \tag{1}
HTHTHT resets to startstartHHTHTH
each step
The costly step is the tail from HT. Unlike THH, which keeps its leading symbol, HTH throws away everything and restarts, which is why HTH takes longer to appear than THH.

#Solve

The three equations give a=2+ba = 2 + b, b=2+cb = 2 + c, and c=1+12ac = 1 + \tfrac{1}{2}a. Substituting, a=4+c=5+12aa = 4 + c = 5 + \tfrac{1}{2}a, so

E[flips to HTH]=a=10.(2)\E[\text{flips to HTH}] = a = 10. \tag{2}

#Compare

HTH lands between THH at 88 and HHH at 1414. The tail from HTHT wipes out all progress, which makes HTH slower than THH, yet its self-overlap is shallower than HHH's, so it still finishes well short of 1414.