[Math] the expected number of flips of an unfair coin until you have 2 more heads than tails

combinatoricsprobability

$p$ is the probability of heads. Note if $p \le 0.5$, the answer is infinity, so assume $p > 0.5$.

What is the expected number of flips of the coin where we have 2 more heads than tails?

Note you would stop flipping the coin when you first encounter the situation where you have 2 more heads than tails.

Best Answer

We only ever need to keep track of the difference between the number of heads, and the number of tails. Moreover, the time it takes to increase this difference by $2$ is twice the time it takes to increase this difference by $1$.

So let's call $x$ the time it takes to go from a difference of $k$ to a difference of $k+1$: for example, the time it takes from the start until you have flipped heads once more than tails.

After the very first coinflip, we're either done (with probability $p$), or we have made progress in the wrong direction and have a difference of $2$ to make up for (with probablity $1-p$). So we have $$x = 1 + (1-p) \cdot 2x$$ or $x = \frac1{2p-1}$.

The answer you want is $2x = \frac2{2p-1}$.

Related Question