About the Coin Flip
Every site has a coin flipper. This one does the two things the others do not. It flips with your browser’s cryptographic random number generator using rejection sampling, so the mapping introduces no bias whatsoever. And then it does the interesting part: it runs real statistical tests on the sequence you just produced and tells you whether it is actually unusual.
Because it almost never is, and that is the point. In a hundred flips of a fair coin, the chance of a run of seven or more heads or tails somewhere in there is about 54 per cent — better than even odds. The longest run averages just under seven. People experience that as a broken coin, a hot hand, or a rigged website, because we expect randomness to alternate politely and it emphatically does not.
So the tool computes the exact probability of your particular longest streak, a runs test for over- and under-alternation, and an exact two-sided binomial on the balance — and it says plainly when you have not flipped enough for any of it to mean anything, rather than printing a confident number over a sample of twelve. The maths was checked against brute-force enumeration of every possible sequence: 2,819 assertions.
Settling something properly. Pick a series length and the tool tracks it, including the exact probability of the score so far arising by chance.
How to Use the Coin Flip
Press flip. Press it a lot. Or use the multipliers to run a hundred or a thousand at once, which is where the statistics start to have something to say. The running tally, the current streak and the longest streak update as you go, and once there are enough flips the tool tells you whether what you are looking at is genuinely unusual for a fair coin.
Your Streak Is Almost Certainly Normal
This is the single most useful thing on the page. In a hundred flips of a perfectly fair coin, the probability of a run of seven or more identical results somewhere in the sequence is about 54 per cent. Better than even odds. The longest run averages just under seven, and a run of ten is not rare enough to raise an eyebrow.
Even in twenty flips, a run of five or more turns up about 46 per cent of the time. People consistently expect randomness to look tidier than it does — to alternate, to self-correct, to avoid clumping. It does none of those things, and the gap between what randomness actually looks like and what we expect it to look like is where gamblers’ fallacies, hot-hand beliefs and accusations of rigged software all come from.
So rather than leaving you to guess, this computes the exact probability of your particular longest streak for your exact number of flips, from the full distribution rather than an approximation.
Why Rejection Sampling, When a Coin Only Has Two Sides
For a coin it makes no practical difference, and it is worth being honest about that: 256 divides evenly by two, so nothing is discarded and no bias would arise either way. It is used here because it is the correct technique and because the same engine drives the dice roller, where it matters a great deal.
There, the difference is real. Take a random byte and reduce it with % 6 and you do not
get a fair die: 256 is not a multiple of 6, so four of the values land twice as often in the remainder
and faces one to four come up slightly more than five and six. The bias is small — about
1.6 per cent of draws are affected — but it is permanent and measurable.
Rejection sampling discards those four values and draws again, which removes the bias completely
rather than reducing it. For a hundred-sided die, nearly 22 per cent of raw draws have
to be discarded, and a tool that skips this step is meaningfully unfair.
What the Three Tests Are Doing
- The runs test (Wald–Wolfowitz) counts how often the sequence switches between heads and tails. Independence predicts a specific average number of switches with a known spread, so the count becomes a z-score. Too many switches means over-alternation — the signature of a human trying to fake randomness. Too few means clumping.
- The longest-run test uses the exact distribution of the longest streak for your number of flips. It is computed by dynamic programming over every possible sequence rather than approximated, and it was checked against brute-force enumeration of all 2n sequences for lengths up to fourteen.
- The balance test is an exact two-sided binomial on the head count — no normal approximation, so it stays correct for small samples where the approximation quietly fails.
A Word About p-Values Before You Get Excited
A p-value below 0.05 does not mean the coin is broken. It means a fair coin would produce something at least this extreme less than one time in twenty — which is to say, about one time in twenty. That is what the threshold is. If you run this tool repeatedly you should expect roughly one “significant” result every twenty attempts from a perfectly fair coin, and if you keep flipping until you see one, you will always find one eventually.
Running three tests at once makes this slightly worse rather than better, which is why the tool reports them separately and does not combine them into a single verdict. It also refuses to give you a p-value at all until there are enough flips for one to mean anything: with twenty flips a fair coin lands anywhere between six and fourteen heads about ninety-five per cent of the time, so almost nothing is detectable, and printing a confident-looking number over that sample would be the dishonest choice.
Think you can produce a convincing fake random sequence yourself? Can You Fake Randomness? uses this same engine to catch you, and almost everybody gets caught. For dice with the same fair generator and a live uniformity check, try the Dice Roller. Browse every Fun & Novelty tool for more.
Frequently Asked Questions
Is this actually random?
It uses your browser's cryptographic random number generator rather than the ordinary one, and it maps the result to heads or tails using rejection sampling so there is no bias at all — not a small bias, none. For a two-sided coin that is easy, because 256 divides evenly by two; the technique matters much more for dice, where it genuinely changes the odds. What no web page can promise is that the underlying generator in your specific browser is perfect, but crypto.getRandomValues is the one browsers are required to make suitable for cryptography.
I got seven heads in a row. Is that unusual?
Almost certainly not. In a hundred flips of a fair coin, the probability of a run of seven or more somewhere in the sequence is about 54 per cent — better than even odds. The longest run averages just under seven. Streaks feel remarkable because we expect randomness to look tidy and alternate politely, and it does not. This tool computes the exact probability of your particular longest run rather than leaving you to guess.
What are the three tests?
The runs test counts how many times the sequence switches between heads and tails and compares that with what independence predicts — too many switches means over-alternation, too few means clumping. The longest-run test uses the exact distribution of the longest streak for your number of flips, computed rather than approximated. The balance test is an exact two-sided binomial on the head count. All three report a p-value, which is the probability a fair coin would produce something at least this extreme.
How many flips do I need before the result means anything?
More than people expect. With twenty flips, a fair coin lands anywhere from six to fourteen heads about ninety-five per cent of the time, so almost nothing is detectable. Around a hundred flips you can start to see a heavily biased coin; detecting a subtle bias — say fifty-five per cent heads — takes several hundred. The tool tells you when your sample is still too small to conclude anything, rather than reporting a p-value that sounds meaningful.
Why does a p-value below 0.05 not mean the coin is broken?
Because one run in twenty of a perfectly fair coin will produce one, by definition. That is what the threshold means. Run this tool repeatedly and you should expect roughly one significant result in every twenty attempts — and if you keep flipping until you get one, you will always get one eventually. This is exactly the trap that makes streaks feel meaningful, and running three tests at once makes it slightly worse rather than better.