🧮 Brain Teaser

The Unfair Coin That Becomes Fair

You have a biased coin with unknown probability pp of heads (where 0<p<10 < p < 1, p1/2p \neq 1/2). You cannot measure pp directly.

Can you use this biased coin to simulate a perfectly fair 50/50 coin flip?

If yes, describe a procedure. What is the expected number of coin flips your procedure requires?

coin flipsymmetryvon Neumannsimulationgeometric distribution

Answer: The Unfair Coin That Becomes Fair

Key Idea / Intuition

The beautiful insight is due to John von Neumann: flip the coin twice. The outcomes HT and TH are not equally likely individually, but by symmetry they are equally likely relative to each other — both have probability p(1p)p(1-p). So declare HT = "heads" and TH = "tails", and simply repeat if you get HH or TT. This extracts perfect fairness from an unknown bias, with no knowledge of pp required whatsoever.


Formal Proof / Solution

The Procedure (Von Neumann's trick)

  1. Flip the biased coin twice.
  2. If the result is HT, output Heads.
  3. If the result is TH, output Tails.
  4. If the result is HH or TT, discard and repeat from step 1.

Why It's Fair

Each pair of flips has the following probabilities:

P(HH)=p2,P(HT)=p(1p),P(TH)=(1p)p,P(TT)=(1p)2.P(HH) = p^2, \quad P(HT) = p(1-p), \quad P(TH) = (1-p)p, \quad P(TT) = (1-p)^2.

The key observation:

P(HT)=p(1p)=(1p)p=P(TH).P(HT) = p(1-p) = (1-p)p = P(TH).

So conditioned on the event that we do not discard (i.e., we got HT or TH), both outcomes are equally likely:

P(output Heads)=P(output Tails)=p(1p)p(1p)+(1p)p=12.P(\text{output Heads}) = P(\text{output Tails}) = \frac{p(1-p)}{p(1-p) + (1-p)p} = \frac{1}{2}.

This holds for any p(0,1)p \in (0,1), with no knowledge of pp needed.

Expected Number of Flips

Each round (2 flips) succeeds with probability:

q=P(HT or TH)=2p(1p).q = P(HT \text{ or } TH) = 2p(1-p).

The number of rounds until success is geometric with mean 1q\frac{1}{q}, so the expected number of coin flips is:

E[flips]=22p(1p)=1p(1p).\mathbb{E}[\text{flips}] = \frac{2}{2p(1-p)} = \frac{1}{p(1-p)}.

Since p(1p)14p(1-p) \leq \frac{1}{4} (maximized at p=1/2p = 1/2), we have:

E[flips]4,\mathbb{E}[\text{flips}] \geq 4,

with equality when p=1/2p = 1/2 (the fair coin case), and the expected number grows to \infty as p0p \to 0 or p1p \to 1 (very biased coins are very wasteful).

Summary Table

| pp | E[flips]\mathbb{E}[\text{flips}] | |------|---------------------------| | 0.50.5 | 44 | | 0.30.3 | 4.76\approx 4.76 | | 0.10.1 | 11.1\approx 11.1 | | 0.010.01 | 101\approx 101 |

The elegance: perfect fairness from unknown bias, at the cost of only expected efficiency.


Reference: Von Neumann, J. (1951). "Various techniques used in connection with random digits." Applied Math Series, 12, 36–38.

Source: Fifty Challenging Problems in Probability with Solutions (Frederick Mosteller) — related folklore; original trick due to von Neumann (1951)

Type: ProbabilitySource: Fifty Challenging Problems in Probability with Solutions (Frederick Mosteller) — related folklore; original trick due to von Neumann (1951)Edit on GitHub ↗