The following charts show the correctness of many of the algorithms in "Bernoulli Factory Algorithms" and show their performance in terms of the number of bits they use on average. For each algorithm, and for each of 100 λ values evenly spaced from 0.0001 to 0.9999:
- 500 runs of the algorithm were done. Then...
- The number of bits used by the runs were averaged, as were the return values of the runs (since the return value is either 0 or 1, the mean return value will be in the interval [0, 1]). The number of bits used included the number of bits used to produce each coin flip, assuming the coin flip procedure for λ was generated using the
Bernoulli#coin()
method in bernoulli.py, which produces that probability in an optimal or near-optimal way.
For each algorithm, if a single run was detected to use more than 5000 bits for a given λ, the entire data point for that λ was suppressed in the charts below.
In addition, for each algorithm, a chart appears showing the minimum number of input coin flips that any fast Bernoulli factory algorithm will need on average to simulate the specified function, based on work by Mendo (2019)[^1]. Note that some functions require a growing number of coin flips as λ approaches 0 or 1. Note that for the 2014, 2016, and 2019 algorithms—
- an ϵ of 1 − (x + c) * 1.001 was used (or 0.0001 if ϵ would be greater than 1), and
- an ϵ of (x − c) * 0.9995 for the subtraction variants.
Points with invalid ϵ values were suppressed. For the low-mean algorithm, an m of max(0.49999, x*c*1.02) was used unless noted otherwise.