## Posts Tagged ‘coin flips’

### Coin Perfection

Saturday, March 28th, 2009

Say you want to flip a perfect coin, but the only coins available are imperfect. First, let’s consider the case where we don’t know the details of the available coins, and would prefer not to measure them.

The simplest strategy is to flip a bunch of coins and determine whether the total number of heads is even or odd. As long as there’s a reasonable number of both heads and tails, the probability of an even number of heads will be close to one half.

Here is a measure of “coin perfection” which behaves additively with respect to the parity algorithm:

$G\left(p\right)=-\mathrm{log}|2p-1|$

I.e., if you have two coins with probabilities of heads $p$ and $q$, and $r$ is the probability that flipping both coins gives the same result, then

$G\left(r\right)=G\left(p\right)+G\left(r\right)$

since $\begin{array}{rl}{e}^{G\left(r\right)}& =|2r-1|\\ & =|2\left(pq+\left(1-p\right)\left(1-q\right)\right)-1|\\ & =|2\mathrm{pq}+2-2p-2q+2\mathrm{pq}-1|\\ & =|4\mathrm{pq}-2p-2q+1|\\ & =|\left(2p-1\right)\left(2q-1\right)|\\ & ={e}^{G\left(p\right)}{e}^{G\left(q\right)}\end{array}$

In particular, $G\left(0\right)=G\left(1\right)=0$ and $G\left(1/2\right)=\infty$ as one would expect; flipping a deterministic coin gets you no closer to perfection, and flipping a single perfect coin makes the parity perfectly random regardless of the other coins.

If we know the exact probability of heads $p$, we can do better than this and produce a perfect coin in a finite expected number of flips. By information theory the best we can hope for is $1/H\left(p\right)$ where

$H\left(p\right)=-p\mathrm{lg}p-\left(1-p\right)\mathrm{lg}\left(1-p\right)$

is the entropy of the coin. Unfortunately determining the exact minimum appears rather complicated, so I’m not going to try to finish the analysis right now.