Tool
Coin Flip Streak Simulator
Flip thousands of coins and see how long the longest run of heads really gets.
Coin Flip Streak Simulator
Theory says the longest head-run in 200 fair flips should sit near 7.6 — the base-2 logarithm of the flip count.
Flip a coin thousands of times and measure the longest unbroken run of heads. Then compare that against what theory says the longest run should be.
The answer is almost always larger than people expect, and that gap is the entire point. In two hundred fair flips the longest head-run is typically seven or eight, and a run of ten is unremarkable — yet a run of six in a real game is enough to convince a room that something is wrong.
Run several batches at once and the spread becomes visible too: the same settings will give you a longest run of six on one batch and eleven on the next, from a generator that has not changed.
How the Coin Flip Streak Simulator works — and why it's fair
Each flip is a single unbiased bit from crypto.getRandomValues, and the simulation walks the sequence keeping three running counts: total heads, the current run length, and the longest run seen. Nothing is stored per flip, which is why a hundred thousand flips completes instantly and uses no memory.
The theoretical prediction shown alongside is the base-2 logarithm of the flip count. That is the standard approximation for the expected longest run of heads in a fair sequence: doubling the number of flips adds roughly one to the expected longest run. It is an approximation, accurate to within about one for any realistic length, and it is the number worth carrying away.
Logarithmic growth is what makes streaks so misleading. Going from 100 flips to 200 does not double the longest run — it adds one. Going from 200 to 2,000 adds about 3.3. So a very long session produces streaks only slightly longer than a short one, which means a run of eight is not evidence of a long session or of a broken generator; it is evidence of about 256 flips.
Running multiple batches surfaces the variance, which the single-number prediction hides. Ten batches of two hundred flips will typically produce longest runs from five to eleven around a mean near seven and a half. The mean matches theory closely; any individual batch may not, and judging a generator from one batch is exactly the error the tool exists to correct.
The head count per batch is reported too, and it makes a related point. A batch of two hundred flips landing 92 heads is a 46% rate, which looks suspiciously low until you note that the standard deviation on two hundred flips is about seven — so anything from 93 to 107 is entirely ordinary, and 92 is barely outside it.
When the Coin Flip Streak Simulator is fair — and when it is not
What it does guarantee
- Every flip is an independent, unbiased fifty-fifty draw from the browser's cryptographic generator.
- Streaks are measured over the full sequence, with no smoothing or exclusion of extreme runs.
- The theoretical prediction is computed from your actual flip count rather than quoted from a table.
What it does not
- A single batch proves nothing about the generator. The variance between batches is large and expected.
- The log-2 prediction is an approximation, typically accurate to about one either way.
- It measures streaks in this simulation only. It cannot tell you anything about a physical coin, which is measurably not fair.
Two worked examples
200 flips, one batch
- Theory predicts a longest head-run near log₂(200) ≈ 7.6.
- Typical observed results run from 5 to 11 across repeated batches.
- About 100 heads expected, with a standard deviation of about 7 — so 92 or 108 are both unremarkable.
20,000 flips, one batch
- A hundred times more flips, but theory predicts only log₂(20,000) ≈ 14.3 — roughly seven more, not seven hundred.
- That logarithmic growth is why a run of eight tells you almost nothing about how long the session was.
- Around 10,000 heads expected, with a standard deviation of about 71.
Where the numbers settle an argument
The commonest use is answering a specific accusation: someone has seen a run of six and concluded the tool is broken. Running two hundred simulated flips in front of them and getting a run of seven from a generator nobody has touched is a faster and more convincing answer than any explanation of independence.
It is a standard classroom demonstration of why human intuition about randomness fails, and it pairs well with the classic exercise of asking students to fake a hundred coin flips. Faked sequences reliably lack long runs — people alternate too much — and this makes the comparison concrete.
Anyone building a game with randomness uses it to calibrate expectations before players do. Knowing that a thousand encounters will contain a run of ten identical outcomes lets you decide in advance whether that is acceptable, rather than discovering it from a complaint.
For the same phenomenon drawn as a path rather than counted as runs, the random walk generator shows the drift. For a single flip, the coin flip is the tool, and the guide on coin flip streaks goes through the arithmetic in more depth.
Frequently asked questions
How long should the longest run be?
Roughly the base-2 logarithm of the number of flips. Two hundred flips gives about 7.6; two thousand gives about 11.
Why does the longest run grow so slowly?
Because the growth is logarithmic. Doubling the flips adds about one to the expected longest run, not double.
My batch gave a run of 12 — is the generator broken?
Almost certainly not. The variance between batches is large; run ten batches and you will see the range for yourself.
Does it count runs of tails as well?
It reports the longest head-run and the longest run either way, so you can see both. They behave identically by symmetry.
Is the log₂ prediction exact?
No, it is a well-known approximation, typically accurate to about one either way. Comparing it against a mean over ten batches shows how close it gets.
How many flips can it simulate?
Up to a hundred thousand per batch, and up to fifty batches. Nothing is stored per flip, so even the maximum completes instantly.
Does this say anything about a real coin?
No. A physical coin is measurably not perfectly fair — it has a slight bias toward the face it started on — and this simulates an ideal one.
Why does the head count vary so much?
Because the standard deviation on n flips is about half the square root of n. On two hundred flips that is seven, so 93 to 107 heads is entirely ordinary.
Can I see the actual sequence?
No — only the summary statistics. A hundred thousand H and T characters is not something anyone can usefully read.