I recently encountered an intriguing question during a mathematical interview: How can one construct a fair binary random variable that outputs either $0$ or $1$ using a biased coin with a head-up probability of $ p $, while minimizing the expected number of coin tosses?
I am aware of the conventional method for simulating a fair coin from a biased one. This method involves the following steps:
- Toss the biased coin twice.
- If the outcomes are both heads (HH) or both tails (TT), disregard the results and start anew.
- If the outcomes are heads-tails (HT), output $0$.
- If the outcomes are tails-heads (TH), output $1$.
With this approach, the expected number of coin tosses $ n $ can be calculated as: \begin{align*} n &= 2 + (p^2 + (1 - p)^2) n \\ &\Rightarrow n = \frac{2}{2p(1 - p)} \end{align*}
However, the interviewer raised a more challenging aspect: devise and implement a strategy such that the expected number of coin tosses approximates the optimal $ \frac{1}{H(p)} $, where $ H(p) = -p \log_2(p) - (1 - p) \log_2(1 - p) $ represents the entropy?
I suspect that this is a systematically solvable problem. Are there any published works that delve into this issue?