Making fairness from bias
You have a coin that's biased, but you don't know the bias. It could favor heads or tails by any amount. Can you use this coin to generate a fair 50/50 outcome?
Von Neumann's trick
Let be the probability of heads. The four possible outcomes of two flips:
| Pair | Probability |
|---|---|
| HH | |
| HT | |
| TH | |
| TT |
Since multiplication is commutative, .
To generate a fair bit from a biased coin: flip twice. If the results differ (HT or TH), output the first flip's result. If the results match (HH or TT), discard and try again. This works for any bias .
Flip an unfair coin twice. Keep only HT and TH results (discard HH and TT). These two outcomes have equal probability regardless of bias.
Slide the bias to extreme values like 0.05 or 0.95. The HT and TH counts stay equal even when the coin is heavily biased.
The cost of fairness
The method discards HH and TT pairs, so it wastes some flips. The probability that a pair is useful is:
This is maximized at (where ) and drops toward 0 as approaches 0 or 1. With a heavily biased coin, you need many attempts to get a usable pair.
This problem tests whether you can work with unknowns. The bias is unknown, but the solution works for every . In interviews, the question checks if you can find structure that doesn't depend on the specific parameter value.