Coin Perfection

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(p) = -\log \left| 2p-1 \right|$$

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(r ) = G(p) + G(r )$$ since $$\begin{aligned} e^{G(r )} &= \left| 2r - 1 \right| \\
&= \left| 2(p q + (1-p)(1-q)) - 1 \right| \\
&= \left| 2pq + 2 - 2p - 2q + 2pq -1 \right| \\
&= \left| 4pq - 2p - 2q + 1 \right| \\
&= \left| (2p-1)(2q-1) \right| \\
&= e^{G(p)}e^{G(q)} \end{aligned}$$

In particular, $G(0) = G(1) = 0$ and $G(½) = \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(p)$ where

$$H(p) = -p \lg p - (1-p) \lg (1-p)$$

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.

comments powered by Disqus