How this calculator works
The calculation tracks the current run length only while no qualifying streak has occurred. Each new flip either extends that run or starts it again. Probability that first reaches the target is accumulated separately, so overlapping opportunities are never treated as independent. Either-side mode tracks both possible current runs. The expected waiting time refers to an unlimited sequence and is shown only for a specified side. Work is limited to two million flip-length state updates.
Formula
For a specified side with chance q, surviving state j advances to j + 1 with probability q and resets to 0 with probability 1 - q. Reaching k is a hit. Expected waiting time = sum from i = 1 to k of q^(-i).
Worked example
For three fair flips, HH occurs in HHH, HHT and THH, so the chance is 3/8. A run of either HH or TT occurs in six of the eight sequences, giving 3/4. Waiting for HH takes six flips on average.
Advertisement
Frequently asked questions
Why not multiply the number of positions by the streak probability?
Potential streak positions overlap and can occur together. Multiplying can double-count sequences and even give probabilities above one.
What if the streak is longer than the flip count?
The event probability is zero. The unlimited expected waiting time can still be calculated for a specified side.
Does a previous run change a fair coin?
No. The model assumes independent flips. A run changes the current state of the event being tracked, not the chance of the next side.