Background
We're given a coin that shows heads with an unknown probability, λ. The goal is to use that coin (and possibly also a fair coin) to build a "new" coin that shows heads with a probability that depends on λ, call it f(λ). This is the Bernoulli factory problem (Keane and O'Brien 1994), and I catalog algorithms to solve it.
Main Question
Prove or disprove: Let f:(D⊆[0,1])→[0,1]. Given a coin that shows heads with probability λ (which can be 0 or 1), it is possible to toss heads with probability f(λ) using the coin and no other sources of randomness (and, thus, f is strongly simulable) if and only if—
- f is constant on its domain, or is continuous and polynomially bounded on its domain (polynomially bounded means, both f and 1−f are bounded below by min(xn, (1−x)n) for some integer n [Keane and O'Brien 1994]), and
- f(0) and f(1) are each 0, 1, or undefined, and
- if f(0)=0 or f(1)=0 or both, then there is a polynomial g(x):[0,1]→[0,1] with computable coefficients, such that g(0)=f(0) and g(1)=f(1) whenever 0 or 1, respectively, is in the domain of f, and such that g(x)>f(x) for every x in the domain of f, except at 0 and 1, and
- if f(0)=1 or f(1)=1 or both, then there is a polynomial h(x):[0,1]→[0,1] with computable coefficients, such that h(0)=f(0) and h(1)=f(1) whenever 0 or 1, respectively, is in the domain of f, and such that g(x)<f(x) for every x in the domain of f, except at 0 and 1.
It's possible that the conditions given are not necessary, and stronger conditions hold; for example: "0 is not in the domain of f, or f can be extended to a Lipschitz-continuous function on [0,ϵ) for some ϵ>0". A tricky example of such a function is f(x)=(sin(1/x)/4+1/2)⋅(1−(1−x)n ) for n≥1 (f(0)=0), which is strongly simulable at 0 and is Lipschitz at, say, [0,0.01]. ((1−x)n is the probability of the biased coin showing zero n times in a row.)
For details, see my progress on this problem.
(In this post, "f(x) is undefined" means that x is not in the domain of f.)
The rest of this page will detail the problem.
Simulable and strongly simulable functions
There are two kinds of factory functions:
- A function f(λ) is simulable if an algorithm exists to toss heads with probability f(λ) given a coin with probability of heads λ (the "biased coin") as well as a fair coin.
- A function f(λ) is strongly simulable if an algorithm exists to toss heads with probability f(λ) given only a coin with probability of heads λ.
Every strongly simulable function is simulable, but not vice versa.
In fact, Keane and O'Brien (1994) showed already that f(λ) is strongly simulable if f is simulable and neither 0 nor 1 is in f's domain (that is, if the biased coin doesn't show heads every time or tails every time). And it's also easy to show that if f is strongly simulable, then f(0) and f(1) must each be 0, 1, or undefined.
However, it's not so trivial to find the exact class of strongly simulable functions when f's domain includes 0, 1, or both.
As one illustration of this, the proof of Keane and O'Brien relies on generating a geometric random variate and using that variate to control which "part" of the target function f(λ) to simulate. This obviously works on all of [0, 1] if the algorithm uses both the biased coin and a separate fair coin. However, if only the biased coin is used in the algorithm, the geometric random variate is generated using fair bits via the von Neumann method, which however will never terminate if λ is either 0 or 1. In addition, a result I found gives sufficient conditions for being strongly simulable when f's domain includes 0, 1, or both. Its proof proceeds by showing, among other things, that the Bernoulli factory for f must flip the input coin and get 0 and 1 before it simulates any fair coin flips via the von Neumann trick.
References