logoalt Hacker News

NameError • 11/19/2024 • 6 replies • view on HN

Easy way to get a fair result from an unfair coin toss: Flip the coin twice in a row, in this case starting with the same side facing up both times, so it's equally unfair for both tosses. If you get heads-heads or tails-tails, discard and start over until you get either heads-tails or tails-heads, which have equal probabilities (so you can say something like HT = "heads" and TH = "tails").

This works even if the coin lands heads 99% of the time, as long as it's consistent (but you'll probably have to flip a bunch of times in that case).


Replies

simcop2387 • 11/19/2024

If anyone wants to look up why this might work, it's a Whitening transform [0]. I can't find the name of the algorithm itself being describe in the parent but there's more than just that for accomplishing the same thing.

0: https://en.wikipedia.org/wiki/Whitening_transformation

➕ show 2 replies
legobmw99 • 11/19/2024

I’ve seen this attributed to John von Neumann, of all people

➕ show 1 reply
mankyd • 11/19/2024

Importantly - you don't have to know the odds of the coin ahead of time, or which side is more likely. You only need to know that it is consistent.

➕ show 1 reply
ant6n • 11/19/2024

What if consecutive unfair coin flips are not independent?

➕ show 1 reply
Aloisius • 11/19/2024

Each flip would need to start with the same side up though, if this paper is correct.