Bernoulli Factory
- Bernoulli factory is a framework that converts random coin tosses with unknown bias into outputs with a target probability via an almost-surely terminating algorithm.
- It employs constructive methods such as Bernstein polynomials, cascade techniques, and finite-state machines to achieve exact simulation under stringent information constraints.
- Applications span exact statistical sampling, MCMC, combinatorial optimization, and quantum systems, while challenges remain in extending finite-automata and multivariable constructions.
Searching arXiv for relevant Bernoulli factory papers. A Bernoulli factory is a randomized procedure that transforms Bernoulli randomness with an unknown parameter into Bernoulli randomness with a prescribed transformed parameter, without numerically estimating that parameter. In the standard single-coin formulation, one is given i.i.d. samples from a Bernoulli source with unknown , and seeks an almost-surely terminating algorithm that outputs a bit satisfying for a specified function (Leme et al., 28 Jun 2026). This framework extends in several directions: to multivariable inputs on the simplex (Leme et al., 28 Jun 2026), to combinatorial outputs associated with vertices of polytopes (Niazadeh et al., 2020), to exact simulation and MCMC for intractable posteriors (Vats et al., 2020), to duality constructions in population genetics and reaction–diffusion models (Koskela et al., 2023), and to quantum settings in which the input is a qubit or “quoin” rather than a classical coin (Patel et al., 2018).
1. Classical definition and existence theory
In the single-coin setting, a Bernoulli factory for is a randomized procedure that, given access to an i.i.d. sequence with , outputs a bit such that
0
The algorithm may toss the input coin adaptively and may use independent randomness, but it is not allowed to learn 1 numerically; it must work for all 2 in the domain (Leme et al., 28 Jun 2026).
A standard one-dimensional characterization recalled in later work is that 3 has a Bernoulli factory iff 4, 5, or 6 is continuous and polynomially bounded, in the sense that there exists 7 such that
8
(Koskela et al., 2023). A closely related formulation states that a function 9 admits a Bernoulli factory if it is continuous and either constant or satisfies a polynomial lower bound away from 0 and 1 (Koskela et al., 2 Oct 2025). This establishes the basic feasibility boundary for classical factories.
Several canonical examples recur across the literature. The function 2 is constructible only on a restricted domain such as 3 in the classical model (Patel et al., 2018). By contrast, 4 is a standard constructible example on 5 (Patel et al., 2018). More generally, Bernoulli factories are exact simulation primitives rather than estimation procedures: they realize transformed probabilities directly from sample paths, stopping rules, and auxiliary randomness.
2. Constructive methods and complexity
A central constructive strand concerns functions expressible through Bernstein polynomials or power series. Mossel and Peres showed that finite-state implementations correspond to Bernstein-polynomial structure, and, in one variable, to rational functions under suitable regularity conditions (Leme et al., 28 Jun 2026). Independently, practical implementations were developed through envelope and cascade methods for linear, concave, and convex functions, including the elbow function 6, with substantial reductions in the number of input bits relative to earlier specific constructions (Thomas et al., 2011).
For functions of the form
7
Mendo gave a simple general Bernoulli factory with exact expected input cost
8
and proved fastness in the sense of an exponential tail for the stopping time (Mendo, 2016). The same paper established an information-theoretic lower bound for any differentiable 9 admitting a fast factory,
0
and showed asymptotic optimality of the construction for broad classes of functions satisfying 1 as 2 (Mendo, 2016). In particular, for 3, 4, the algorithm yields 5, including the case 6 (Mendo, 2016).
Linear Bernoulli factories form another major line because they are foundational for analytic constructions. For 7, Huber developed a new algorithm that, for small values of 8, requires roughly only 9 coin flips to generate a 0 coin, and for larger 1 improved the best known expected cost bound to about 2 under 3 (Huber, 2015). The same work extended the construction to the multivariate linear case 4 (Huber, 2015).
A more recent development introduced a debiased Bernoulli factory based on random truncation of a telescoping series of consistent estimators. For 5 with 6, the construction yields an estimator 7 almost surely, with 8, where the random sample size 9 is independent of the outcomes of the Bernoulli0 inputs (Koskela et al., 2 Oct 2025). This can be viewed both as a Bernoulli factory with outcome-independent sample size and as a constructive 1-factory (Koskela et al., 2 Oct 2025).
3. Finite-automata factories and multivariable structure
A finite-automata Bernoulli factory is implemented by a finite-state machine that reads input coin tosses one by one, possibly uses finite internal randomness, and eventually halts and outputs 2 or 3 (Leme et al., 28 Jun 2026). In the Mossel–Peres framework, such factories correspond to representing 4 as
5
with 6 and 7 Bernstein polynomials on the simplex (Leme et al., 28 Jun 2026). In the single-variable setting, this yields the equivalence between finite-automata Bernoulli factories and rational functions of 8, under the regularity conditions used there (Leme et al., 28 Jun 2026).
The multivariable situation is subtler. A multivariable Bernoulli factory has access to independent coins with unknown biases 9 in the simplex
0
and must output a Bernoulli1 bit (Leme et al., 28 Jun 2026). Mossel and Peres claimed that any rational function 2 can be simulated via blocks, but a 2026 note shows that the multivariable extension of this characterization is false (Leme et al., 28 Jun 2026).
The obstruction is boundary behavior. Pólya’s theorem applies when a homogeneous polynomial is strictly positive on the closed simplex 3, but in several variables a coprime denominator can vanish on 4 without sharing a removable common factor with the numerator (Leme et al., 28 Jun 2026). Paes Leme and Schneider give an explicit counterexample on 5: 6 which is polynomially bounded away from 7 and 8, hence admits a general Bernoulli factory by Morina’s characterization, but cannot be implemented by a finite-automata Bernoulli factory (Leme et al., 28 Jun 2026). This establishes a strict separation between general and finite-state simulation already for three variables.
The resulting picture is asymmetric. In one variable, rationality and finite-automata simulability coincide under the standard hypotheses (Leme et al., 28 Jun 2026). In higher dimensions, general Bernoulli factories are characterized analytically by continuity plus polynomial lower bounds near the boundary, whereas finite-automata factories form a narrower algebraically constrained subclass, at least containing those functions with a Bernstein rational representation (Leme et al., 28 Jun 2026).
4. Combinatorial and polyhedral Bernoulli factories
A combinatorial Bernoulli factory replaces scalar output by a random vertex of a polytope. Given Bernoulli access to a vector 9, the task is to output a randomized vertex 0 such that 1 (Niazadeh et al., 2020). For example, in the perfect matching polytope, one is given Bernoulli access to the entries of a doubly stochastic matrix 2 and asked to sample a perfect matching such that the probability of each edge 3 is exactly 4 (Niazadeh et al., 2020).
The main characterization is exact: a polytope 5 admits a Bernoulli factory iff it is the intersection of 6 with an affine subspace (Niazadeh et al., 2020). The construction is algebraic. One identifies a family of Bernstein polynomials 7 satisfying
8
and then uses a Bernoulli race to output 9 with probability proportional to 0 (Niazadeh et al., 2020). The main technical tool behind the general construction is a connection between these polynomials and the geometry of zonotope tilings (Niazadeh et al., 2020).
These ideas lead to explicit factories for important combinatorial polytopes. For the perfect matching polytope, the resulting factory is deeply connected to the combinatorial enumeration of arborescences (Niazadeh et al., 2020). For flow-based polytopes, later work constructed explicit Bernoulli factories for integral 1-polytopes defined by network flow constraints, including paths, circulations, and 2-flows (Niazadeh et al., 2022). In that setting, the output is a vertex 3 such that each edge 4 is included with probability 5, equivalently 6 (Niazadeh et al., 2022).
The flow-based construction uses directed trees, arborescences, and matrix-tree-theorem identities. The resulting explicit factory generalizes earlier constructions for bipartite perfect matchings and again exhibits a tight link between Bernoulli factory design and algebraic combinatorics (Niazadeh et al., 2022). This suggests a broader principle: exact randomness transformation from coordinate-wise Bernoulli access is naturally compatible with affine slices of the hypercube, and explicit factories for such slices often mirror the combinatorial structure of their vertex sets.
5. Statistical, probabilistic, and algorithmic applications
Bernoulli factories are widely used as exact simulation primitives. In exact sampling for intractable probability distributions, a Bernoulli factory for a linear function 7 is used inside a rejection sampler for the mixture index in a regenerative representation of the stationary law of a geometrically ergodic Markov chain (Flegal et al., 2010). There, the unknown 8 is a tail probability 9 of a regeneration time, and the Bernoulli factory converts simulation access to 0 into an exact acceptance decision (Flegal et al., 2010). This enabled proof-of-concept exact sampling for a univariate Metropolis–Hastings sampler, a bivariate Gibbs sampler, and a Bayesian one-way random effects model (Flegal et al., 2010).
Bernoulli factories also enter exact MCMC for intractable posteriors through acceptance rules that are not explicit functions of target-density ratios. A family of “portkey Barker’s algorithms” introduces acceptance probabilities of the form
1
with symmetric 2, and uses stable Bernoulli factories based on upper or lower local bounds on 3 (Vats et al., 2020). These methods are exact and computationally more efficient than the current state-of-the-art in applications to Bayesian inference for diffusions and MCMC on constrained spaces (Vats et al., 2020).
A distinct theoretical application appears in population genetics and reaction–diffusion theory. The Keane–O’Brien Bernoulli factory, in a form where the random number of input coins is independent of their outcomes, is used as a structural device to derive duality relations for Wright–Fisher diffusions with general frequency-dependent selection and for Allen–Cahn equations with general nonlinear forcing terms (Koskela et al., 2023). In the Wright–Fisher setting, the drift
4
is linked to a branching-coalescing ancestral process whose branching law is dictated by the Bernoulli factory representation of 5 (Koskela et al., 2023). In the Allen–Cahn setting, the same factory induces a branching/voting mechanism in a branching Brownian motion dual (Koskela et al., 2023). This is the first connection drawn between Bernoulli factories and duality in models of population genetics (Koskela et al., 2023).
These applications illustrate two complementary roles. In computational statistics, Bernoulli factories supply exact accept/reject subroutines when only probabilistic access to model quantities is available (Flegal et al., 2010). In stochastic-process theory, they can encode nonlinear drift or forcing through branching mechanisms whose law is determined by the factory itself (Koskela et al., 2023).
6. Quantum Bernoulli factories
Quantum Bernoulli factories replace the classical coin by a qubit whose measurement reproduces the unknown bias. A standard quoin encoding is
6
so that measurement in the computational basis yields a Bernoulli7 outcome (Patel et al., 2018). A quantum Bernoulli factory takes an i.i.d. supply of such states and uses quantum operations and measurements to realize a target function 8 in the output distribution (Patel et al., 2018).
Experimentally, quantum resources can outperform classical ones. A photonic implementation demonstrated two quantum Bernoulli factories: a single-qubit coherence-only protocol and a two-qubit protocol using entangling measurements (Patel et al., 2018). For the target function 9 or a capped variant, the former consumed three orders of magnitude fewer resources than the best known classical method, while the latter offered a further five-fold reduction (Patel et al., 2018). More recently, an experiment on IBM superconducting hardware used Bell-basis measurements of two identical input quoins to realize an exact fair coin 00, the classically inconstructible function 01, and the classically inconstructible Bernoulli doubling primitive 02 in symmetrized form (Roy, 5 Feb 2026).
A further development concerns quantum-to-quantum Bernoulli factories, in which both input and output are quantum states. Using the stereographic parameterization
03
the task is to transform 04 into 05 for a prescribed function 06 (Hoch et al., 2024). A modular integrated photonic implementation showed that inversion, product, and sum operations on the parameter 07 can be realized by fixed interferometric modules, and because rational functions are generated by these field operations, the scheme is universal for the class of quantum-to-quantum Bernoulli factory functions realizable in this framework (Hoch et al., 2024).
Subsequent work formalized complexity and multi-functional variants of the quantum-to-quantum model. For multivariate rational functions 08, the required number of input coin states in each variable equals the degree in that variable, and an explicit optimal success probability was derived (Hoch et al., 11 Dec 2025). The same work also analyzed multi-functional factories, in which a single unitary can implement several Bernoulli-factory transformations depending on a control input (Hoch et al., 11 Dec 2025). This line of research positions Bernoulli factories as coherent randomness-processing primitives for quantum algorithms, Bayesian inference, Monte Carlo methods, and blind quantum computation (Hoch et al., 11 Dec 2025).
7. Conceptual synthesis and open structure
Across its classical, combinatorial, and quantum forms, the Bernoulli factory problem is a theory of exact randomness transformation under information constraints. The input parameter is unknown, but sample access to Bernoulli or quoin realizations is available. The central question is not approximation but implementability: which transformations can be realized exactly, with what resources, and under what structural constraints.
The classical theory now has several sharp dividing lines. In one variable, continuity plus polynomial lower bounds characterize general feasibility (Koskela et al., 2023). For important subclasses, constructive methods with explicit complexity bounds are available (Mendo, 2016). For finite-state implementations, the single-variable picture is algebraic and clean, but the multivariable rational characterization fails (Leme et al., 28 Jun 2026). In combinatorial settings, the exact polyhedral criterion is affine: Bernoulli factories exist precisely for affine slices of the hypercube (Niazadeh et al., 2020). In quantum settings, the reachable function classes and achievable efficiencies differ substantially from the classical ones, and experimentally demonstrated advantages already exist (Patel et al., 2018).
Several open directions are explicitly identified in the recent literature. For finite-automata multivariable factories, a full characterization beyond Bernstein-rational representability remains unknown (Leme et al., 28 Jun 2026). For exact statistical simulation, practical efficiency still depends strongly on problem-specific bounds and model structure (Flegal et al., 2010). For debiased and outcome-independent-sample-size factories, relaxing smoothness assumptions while preserving 09-valued unbiasedness is an open question (Koskela et al., 2 Oct 2025). In the quantum-to-quantum regime, rational-function simulability is understood, but broader approximation and fault-tolerant implementations remain natural next steps (Hoch et al., 11 Dec 2025).
Bernoulli factories therefore occupy a distinctive position at the interface of probability, exact simulation, combinatorics, and quantum information. They are simultaneously a foundational model of randomness processing and a practical subroutine for algorithms that require exact transformed sampling from unknown parameters.