Coin flip

One bit each from the operating system's random source — with the longest run, and the exact chance of a run that long, because people call a fair coin rigged at about six. Nothing you type here leaves your browser — it is worked out on your own device, so there is nothing to send and nothing to log.

This page will not fall back to Math.random(). Everything here is drawn from crypto.getRandomValues(), which the browser backs with the operating system's cryptographic source. If that is unavailable the page says so and produces nothing — because output from a weak source looks exactly like output from a strong one, and that is the whole problem.

A run of six heads is not a rigged coin

People are very bad at this. Shown a hundred coin flips, most will call a run of six heads suspicious — and a run of six or more happens in 54.6% of hundred-flip sequences. It is more likely than not.

Longest run of heads in 20 flipsin 100 flips
5 or more25.0%81.0%
6 or more12.2% 54.6%
7 or more5.8%31.8%
8 or more2.7%16.9%

These are exact, worked out by walking every possible sequence's run-length state rather than by simulating. And they cut both ways: in twenty flips a run of six is genuinely unusual at 12.2%. The same run means different things depending on how long you watched.

This is the thing people get backwards. A sequence that alternates neatly — H T H T H T — looks far more random than one with a clump in it, and is far less likely.

The coin has no memory

After five heads, the chance of a sixth is one half. Not less, because a tail is “due”; not more, because the coin is “hot”. Both are the same mistake, which is imagining the coin knows what it did last.

What is true is that long runs are rare before you start. The chance of six heads from a standing start is 1 in 64. The chance of a sixth head given five already is 1 in 2. Nothing changed about the coin between those two sentences; the difference is entirely in what you already know.

Where the randomness comes from

Each flip is one bit from crypto.getRandomValues(), backed by the operating system. Not Math.random(), and there is no fallback: if the source is missing the page says so and produces nothing.

A real coin, incidentally, is not quite fair either — a flipped coin is slightly more likely to land the same way up as it started, because it precesses rather than tumbling cleanly. This page has no such excuse.

Where to go next