A Practical Implementation of the Bernoulli Factory
  The Bernoulli Factory is an algorithm that takes as input a series of i.i.d. Bernoulli random variables with an unknown but fixed success probability $p$, and outputs a corresponding series of Bernoulli random variables with success probability $f(p)$, where the function $f$ is known and defined on the interval $[0,1]$. While several practical uses of the method have been proposed in Monte Carlo applications, these require an implementation framework that is flexible, general and efficient. We present such a framework for functions that are either strictly linear, concave, or convex on the unit interval using a series of envelope functions defined through a cascade, and show that this method not only greatly reduces the number of input bits needed in practice compared to other currently proposed solutions for more specific problems, and is easy to specify for simple forms, but can easily be coupled to asymptotically efficient methods to allow for theoretically strong results. 
A.C. Thomas and Jose H. Blanchet
stat.AP