Probability & Statistics

HTH Before HHT

Flip a fair coin until either HTH or HHT shows up as three in a row. The two triplets look interchangeable, so are they really equally likely to arrive first?

solvedhard2 min

You flip a fair coin repeatedly. What is the probability that the pattern HTH appears before the pattern HHT?

Reveal solutionHide solution

#The hidden asymmetry

The triplets are not symmetric, because of what each shares with the other. Once two heads in a row appear, a single following tail finishes HHT immediately, whereas reaching HTH from that same HH is impossible without passing through HHT first. That trap is what tilts the race.

#The state machine

Track the longest current suffix that is a prefix of either target. There are four transient states, the start \varnothing, then HH, HHHH, and HTHT, plus two absorbing states WW for HTH and LL for HHT. Each toss is fair.

startHHHHTHHTHTHHHTTHTHT
Every edge has probability one half. The only way out of HH is a tail into HHT, so once two heads land in a row the race is lost for HTH. That dead end is why HTH arrives first only one third of the time.

#The transition matrix

Ordering the states ,H,HH,HT,W,L\varnothing, H, HH, HT, W, L, one toss moves the chain by

P=(12120000001212000012001212000120000010000001).(1)P = \begin{pmatrix} \tfrac12 & \tfrac12 & 0 & 0 & 0 & 0\\[2pt] 0 & 0 & \tfrac12 & \tfrac12 & 0 & 0\\[2pt] 0 & 0 & \tfrac12 & 0 & 0 & \tfrac12\\[2pt] \tfrac12 & 0 & 0 & 0 & \tfrac12 & 0\\[2pt] 0 & 0 & 0 & 0 & 1 & 0\\[2pt] 0 & 0 & 0 & 0 & 0 & 1 \end{pmatrix}. \tag{1}

The last two rows are absorbing, each a lone 11 on the diagonal. From HHHH a tail drops the chain into LL, and from HTHT a head lifts it into WW.

#Absorption equations

Let ai=P(HTH firststate i)a_i = \PP(\text{HTH first} \mid \text{state } i), with aW=1a_W = 1 and aL=0a_L = 0. Reading the transient rows,

a=12a+12aH,aH=12aHH+12aHT,(2)a_{\varnothing} = \tfrac12 a_{\varnothing} + \tfrac12 a_H, \qquad a_H = \tfrac12 a_{HH} + \tfrac12 a_{HT}, \tag{2}aHH=12aHH+12(0),aHT=12(1)+12a.(3)a_{HH} = \tfrac12 a_{HH} + \tfrac12 (0), \qquad a_{HT} = \tfrac12 (1) + \tfrac12 a_{\varnothing}. \tag{3}

The third equation forces aHH=0a_{HH} = 0, the dead end. The first gives a=aHa_{\varnothing} = a_H. Then aH=12aHTa_H = \tfrac12 a_{HT} and aHT=12+12a=12+12aHa_{HT} = \tfrac12 + \tfrac12 a_{\varnothing} = \tfrac12 + \tfrac12 a_H. Substituting aH=12aHTa_H = \tfrac12 a_{HT},

aHT=12+14aHT    aHT=23,aH=a=13.(4)a_{HT} = \tfrac12 + \tfrac14 a_{HT} \implies a_{HT} = \tfrac23, \qquad a_H = a_{\varnothing} = \tfrac13. \tag{4}

#Result

Starting from \varnothing,

P(HTH before HHT)=13.(5)\PP(\text{HTH before HHT}) = \tfrac13. \tag{5}

Once the chain reaches HHHH it can only end as HHT, so HHT wins two times out of three even though the triplets seem alike.