P ProbLab
Tools/Coin Flip Sequence Analyzer

Coin Flip Sequence Analyzer

Compute the probability of any specific sequence (e.g. HTHTHT), the expected length of the longest streak in N flips, and visualize the underlying Markov chain. Includes a gambler's-fallacy debunker at the bottom.

Setup

Advertisement

Key results

Markov chain (transition diagram)

Two states: previous flip was H or T. Each transition has probability ½. The chain is memoryless except for the previous state.

Streak probability table

Streak length kP(at least one streak ≥ k)

Why this tool exists

"What are the odds of getting 5 heads in a row?" is one of the most-Googled probability questions on the internet. Most answers are wrong or misleading — they either ignore dependence (each flip is independent) or compute the wrong event ("5 heads in 5 flips" vs "5 heads in a row anywhere in N flips"). This tool computes the right thing and shows why the gambler's fallacy fails.

Who uses it

  • Educators teaching the difference between independent trials and conditional probability.
  • Sports bettors checking "streak" claims in team performance.
  • Anyone who's argued with a friend about whether 5 heads in a row is "due" to flip tails next.

How to read the output

For N flips, "P(at least one streak ≥ k)" is the chance that somewhere in those N flips there's a run of k or more identical outcomes. Expected longest streak is roughly log₂(N) − 1 for fair coins, so in 100 flips the expected longest streak is about 5–6, and in 1000 flips it's about 8–9.

Limitations

  • Pattern matching uses the exact Markov-chain analytical formula; we do not enumerate for N > 1000 to avoid floating-point blow-up.
  • "At least one streak" treats H and T runs symmetrically — for biased coins this tool does not apply.

Gambler's fallacy, formally

If you have just observed 5 heads in a row on a fair coin, the probability the next flip is heads is still exactly ½. The sequence of 5 heads has probability (½)⁵ = 1/32 ≈ 3.1%, which is rare but not rare enough to "balance out". To balance out, you'd need to flip about 32 more heads to make the long-run ratio 50%, but that's not how individual flips work. The Markov chain here shows exactly this: the next state depends only on the previous flip, not on the streak history.

Frequently asked questions

How do I use Coin Flip Sequence Analyzer step by step without mistakes?
Follow the order given in the usage section: Analyze coin-flip sequences: probability of any pattern, longest expected streak, Markov-chain transition diagram, and gambler's fallacy debunker. The step-by-step part matters less than the unit check that sits inside it. Confirm every unit matches the thing you are actually trying to measure before you press calculate - that single check catches more wrong answers than any other habit, and it costs about ten seconds.
What are the common mistakes when using Coin Flip Sequence Analyzer?
Most common mistakes come down to four habits: entering 20 when the field expects 0.2 because the field is a percentage; leaving a field blank and accepting the default without checking what it stands for; changing one input and reading a result that was calculated before the change; and quoting the output as an exact figure when the page describes it as a reference estimate. Press calculate again after any edit, and treat the number as a reference point rather than a final answer.
How do I read the result from Coin Flip Sequence Analyzer?
Read the final figure first, then come back to this section for the conditions behind it: For N flips, "P(at least one streak ≥ k)" is the chance that somewhere in those N flips there's a run of k or more identical outcomes. Expected longest streak is roughly log₂(N) − 1 for fair coins, so in 100 flips the expected longest streak is about 5–6, and Keep two things apart: the number itself, which comes from the values you typed, and the assumptions it depends on, which decide whether that number is meaningful. The page sets out what a higher or lower result means for your case, so check that direction as well as the magnitude.
Can I act on the Coin Flip Sequence Analyzer result directly?
Treat it as one reference sheet before you decide, rather than as the answer itself: Pattern matching uses the exact Markov-chain analytical formula; we do not enumerate for N > 1000 to avoid floating-point blow-up. "At least one streak" treats H and T runs symmetrically — for biased coins this tool does not apply. The output describes a magnitude under the conditions you entered. It does not include what it actually costs to act, what might change while you act, or how the other side behaves. Before you commit, compare the result against reality and note which assumptions do not hold where you are.