Generator Grove

Coin Flip Generator

Press flip. Then keep pressing: the tally, the streaks and the odds build up across the whole session, so you can see whether that run of six heads is remarkable or completely ordinary.

Nothing flipped yet.

Flips0
Heads0
Tails0
Gap, heads minus tails0
Typical gap at this many flips
Longest run, either face
Longest heads run
Longest tails run
Expected longest run
Odds of a run that long
Odds of a gap that wide
Current run

One flip is trivial. The hundredth is where the arguments start

Nobody needs software to flip a coin once. What people actually arrive with is a dispute: somebody has seen six heads in a row and wants to know whether the coin is broken. That question has a precise answer, and this page computes it rather than offering reassurance.

Every flip joins a running session, and the panel scores that session two ways. The head count is measured against the full binomial distribution — the exact tail sum, not a normal approximation — and the longest streak against the exact distribution of run lengths. Both produce a number, and the number is almost always more boring than the argument was.

Why a long streak is not evidence of a biased coin

In 100 fair flips, the expected longest run of a single face is just under seven. A run of at least seven turns up in 54.2% of sessions and a run of at least eight in 31.5%. Eight heads in a row somewhere inside a hundred flips is not a red flag; it happens in roughly one session in three.

The figure people compare it against answers a different question. A nominated stretch of eight flips comes up all heads once in 256 tries, or 0.39%. A run of eight of either face appearing somewhere in a hundred flips happens 31.5% of the time. Same coin, same data, about eighty times apart — and it is the second question that describes what you noticed.

Short sessions behave the same way: over 20 flips the expected longest run is about 4.7, and five or more in a row appears 45.8% of the time.

Nothing is ever "due"

The gambler's fallacy is the belief that a coin owes you a correction. It does not. After six heads the seventh flip is still 50/50, because neither a physical coin nor crypto.getRandomValues has any mechanism for carrying the first six forward.

The law of large numbers is real, but it is about the proportion, not the difference. The share of heads converges towards one half. The raw gap between heads and tails does not shrink — on average it grows, roughly with the square root of the number of flips.

After 100 flips the average gap is about 8. After 10,000 it is about 80: ten times wider in absolute terms, yet as a share of the flips made it has fallen from 8% to 0.8%. An early imbalance is never repaid. It is diluted.

How wide is normal

For n fair flips the head count has a standard deviation of the square root of n, divided by two. At 100 flips that is 5, so 45 to 55 heads covers 72.9% of sessions and 40 to 60 covers 96.5%. Landing on exactly 50 is the single most likely outcome and still happens only 8.0% of the time.

The panel turns your own tally into the same kind of statement: a description of one session, not a verdict on the coin. That is why the tool never prints the word "biased".

Where the flips come from

Flips are drawn from crypto.getRandomValues, your browser's cryptographically secure random source. With the chance of heads left at 50, the page uses the bits of those random words directly, one bit per flip. Because two divides evenly into the number of possible bit patterns there is no modulo bias to correct and no rejection step is needed — worth saying only because it is not true of most ranges.

Change the chance of heads and each flip consumes a whole 32-bit word instead, compared against your percentage scaled across the 32-bit range, so the delivered probability differs from the number you typed by less than two to the power of minus 32. Set it to 55, flip a few thousand times, and watch how long the evidence takes to arrive.

Frequently asked questions

How many flips does it take to prove a coin is biased?

Far more than most people expect, and it depends on the size of the bias. A coin landing heads 55% of the time reaches a two-sided p-value of 0.05 in only about half of 400-flip runs, and roughly four runs in five at 800 flips. A blunter 60/40 coin is easier: about half of 100-flip runs get there, and about four in five at 200. Twenty flips distinguishes nothing.

Can I trust the p-value if I keep flipping until it looks interesting?

No, and that is the honest limitation of a live readout. Stop the moment the number drops below 5% and you will get there eventually even with a perfectly fair coin, because you are taking hundreds of looks at the same growing dataset. Decide the number of flips before you start, and read the panel once, at the end.

Is this good enough to settle a bet or make a real decision?

For deciding who washes up or who kicks off, yes. For anything with money or a legal consequence attached, no: there is no log, no timestamp and no witness, the button can be pressed again until the answer suits, and a browser's random source cannot be audited after the fact.

Are the flips generated on a server?

No. Everything happens in the page on your own device, so a flip makes no network request and the tool keeps working if your connection drops after the page has loaded. Nothing you type or flip is uploaded or stored. The site carries no advertising yet; when it does, the ad slot will load third-party resources on its own account — that traffic is separate and never carries your session with it.

What this tool will not do

It does not simulate the physics of a tossed coin. It tests one hypothesis — that the two faces are equally likely and independent — and looks at only two features of your sequence, the total and the runs. A perfectly alternating sequence would pass both and is obviously not random. Sessions cap at 100,000 flips, nothing is saved between visits, and there is no dice or multi-coin mode.