Sunday, November 8, 2020

Von Neumann's fair coin simulator

For any $p \in (0,1)$, von Neumann showed that an unfair coin which shows heads with probability $p$ can be used to simulate a fair coin by flipping twice, ignoring/redrawing for HH or TT and associating HT with T and TH with H. The issue is that depending on the value of $p,$ one might need to ignore/redraw for HH and TT outcomes for a very large number of tries before getting either TH or HT and exiting.

For what values of $p \in (0,1)$ is it possible to simulate a fair coin in at most $N$ flips?

While the phrasing on the question is a bit vague, I will assume two main frameworks for what "possible" means:

1) For what values of $p \in (0,1)$ is the expected number of flips needed to exit less than or equal to $N$?; or

2) Given some value of $q \in (0,1),$ for what values of $p \in (0,1)$ does the probability that the simulation exists in less than or equal to $N$ exceed $q$?

Let $T$ be the number of flips of the van Neumann simulator needed to exit. The probability that the van Neumann simulator exits after in one flip is $\mathbb{P}\{T = 1\} = 2p(1-p).$ The probability for $k > 1$ that it exits in $k$ flips is $\mathbb{P}\{ T = k \} = 2p(1-p) \cdot (1 - 2p(1-p))^{k-1}.$ So the average is \begin{align*}\mathbb{E}[T] &= \sum_{k=1}^\infty k \mathbb{P} \{ T = k \} = \sum_{k=1}^\infty k 2p(1-p) (1 - 2p(1-p))^{k-1}\\ &= 2p(1-p) \frac{1}{(1 - (1-2p(1-p)))^2} = \frac{1}{2p(1-p)}.\end{align*}

So under framework 1, the question becomes solving for $p \in (0,1)$ such that $$\mathbb{E}_p [T] = \frac{1}{2p(1-p)} \leq N.$$ Thus the solution is $$p \in \left[\frac{1 - \sqrt{1-2/N}}{2}, \frac{1 + \sqrt{1 - 2/N}}{2} \right].$$

Under framework 2, the question becomes for some $q \in (0,1),$ solving for $p \in (0,1)$ such that $$\mathbb{P}_p \{ T \leq N \} = \sum_{k=1}^N 2p(1-p) (1 - 2p(1-p))^{k-1} = 1 - (1 - 2p(1-p))^N \geq q.$$ Since $2p(1-p) \in [0,0.5]$ for all $p \in (0,1),$ if $q > 1-2^{-N},$ then $\mathbb{P}_p \{T \leq N \} \lt q,$ for all $p \in (0,1).$ But for any $q \in [0, 1-2^{-N}],$ then $\mathbb{P}_p \{T \leq N \} \geq q$ for $$p \in \left[ \frac{1 - \sqrt{2 \sqrt[N]{1-q} - 1}}{2}, \frac{1 + \sqrt{ 2 \sqrt[N]{1-q} - 1}}{2} \right].$$

No comments:

Post a Comment