Waiting for tail then head
A biased coin lands heads with probability and tails with probability . It is flipped until a tail is immediately followed by a head.
Find the expected number of flips.
Fractions, decimals with at least 3 significant digits, and expressions such as sqrt(2)/2, e^-1 or pi/4.
The pattern TH has no overlap with itself: once you have a tail, a head finishes the pattern and another tail changes nothing.
Split the wait into two parts: the wait for the first tail, then the wait for the first head after it.
h
s Shown after a correct answer. Revealing it first marks the problem as seen, not solved.
Idea. The pattern TH appears exactly at the first head that comes after the first tail. So the wait is two geometric waits added together.
Step 1: the first tail. Each flip is a tail with probability , so the number of flips up to and including the first tail is geometric with mean .
Step 2: then a head. After that tail, every further tail keeps you in the same situation (the last flip is still a tail), and the first head completes TH. So this wait is geometric with success probability , with mean .
Step 3.
In general. With and , the wait for TH is . The same holds for HT. For a fair coin it is 4, while HH takes 6 on average: HH can overlap with itself, and a failed attempt at HH throws away the head you had.