Learn / Library / Probability
Waiting for a coin pattern
A biased coin lands heads with probability and tails with probability , with independent flips. What is the expected number of flips until the pattern heads, tails, heads first appears in consecutive flips? Give a fraction a/b in lowest terms.
Checking an answer needs JavaScript. The hint and the solution open without it.
Hint
Track the longest suffix of the flips that matches the start of the pattern: nothing, heads, or heads then tails.
Solution
- Let , , be the expected further flips when the matched suffix is empty, heads, or heads then tails.
- From empty: , so .
- From heads: a head keeps us there and a tail moves on, so , giving .
- From heads then tails: a head finishes, a tail resets, so .
- Combining gives , so and .
Answer: