Quant Memo
Core

Making a Fair Coin From a Biased One

Von Neumann's trick throws away exactly the information that carries the bias, by only ever looking at pairs of flips that disagree.

Prerequisites: How to Attack a Brainteaser

You're handed a coin that lands heads with some unknown probability p1/2p \ne 1/2 — you don't know pp, and it could be close to 0 or 1. Using only this coin, produce a perfectly fair 50/50 outcome. It looks like you need to know pp to correct for it. You don't.

The puzzle and the trick

Given a biased coin with unknown bias pp, construct a procedure using only flips of that coin that outputs "heads" or "tails" with probability exactly 1/21/2 each.

The move. Flip the coin twice. If the two flips come out the same (HH or TT), discard the pair and flip twice again. If the two flips disagree (HT or TH), stop and output "heads" if the result was HT, or "tails" if it was TH.

Why it's exactly fair. The probability of HT is p(1p)p(1-p), and the probability of TH is (1p)p(1-p)p — the same expression, in either order, because flips are independent. These two probabilities are always equal, for any pp whatsoever, even though you don't know what pp is. Conditioning on "the pair disagreed" (i.e., throwing away the HH and TT pairs and only looking at HT/TH), the two remaining outcomes each have probability exactly p(1p)2p(1p)=12\dfrac{p(1-p)}{2p(1-p)} = \dfrac12.

Numerical check. Say p=0.9p = 0.9 (a very biased coin). P(HT)=0.9×0.1=0.09P(\text{HT}) = 0.9 \times 0.1 = 0.09. P(TH)=0.1×0.9=0.09P(\text{TH}) = 0.1 \times 0.9 = 0.09. Identical, as promised — the bias cancels because it appears once as pp and once as (1p)(1-p) in each ordered pair, regardless of which one plays which role.

HH: p² discard TT: (1-p)² discard HT: p(1-p) output heads TH: (1-p)p output tails p(1-p) = (1-p)p always — equal, whatever p is conditioned on {HT, TH}, each has probability exactly 1/2
Only the disagreeing outcomes are kept, and the bias term appears identically in both, so it cancels exactly.

Two independent flips of a biased coin have the same probability whichever order the two different outcomes occur in — p(1p)=(1p)pp(1-p) = (1-p)p — because multiplication doesn't care about order. Discard the agreeing pairs and condition only on the disagreeing ones, and the bias vanishes without ever needing to be measured.

The number of pairs you need to flip before getting a disagreement is itself random and, if pp is close to 0 or 1, can be large in expectation — the procedure is exactly fair but not fixed-length. Don't confuse "unbiased" with "fast."

This is a real technique, not just a puzzle: hardware random-number generators built from physically biased sources (thermal noise, jitter) use exactly this von Neumann de-biasing step before the output is trusted for cryptographic or simulation use.

Related concepts

Practice in interviews

Further reading

  • von Neumann, Various Techniques Used in Connection with Random Digits (1951)
ShareTwitterLinkedIn