`BernoulliFactory.expMinus`

— Method`expMinus(f::F, λ::Float64, rng::RNG=GLOBAL_RNG) where {F<:Function, RNG<:AbstractRNG}`

Input:

`f()`

simulates Bernoulli(p) random variates (of type Bool)`λ >= 0`

`[rng]`

the RNG to used by the algorithm (does not affect f)

Output: `X, flips`

`X`

is a Bernoulli(exp(-λ*p)) variate`flips`

is the number of calls of f()

`BernoulliFactory.inverse`

— Method`inverse(f::F, C::Float64, ϵ::Float64, rng::RNG=GLOBAL_RNG) where {F<:Function, RNG<:AbstractRNG}`

Input:

`f()`

simulates Bernoulli(p) random variates (of type Bool)`C ∈ [0,p)`

`ϵ ∈ (0,1)`

satisfying p > C + ϵ.`[rng]`

the RNG to used by the algorithm (does not affect f)

Output: `X, flips`

`X`

is a Bernoulli(C/p) variate`flips`

is the number of calls of f()

`BernoulliFactory.linear`

— Method`linear(f::F, C::Float64, ϵ::Float64, rng::RNG=GLOBAL_RNG) where {F<:Function, RNG<:AbstractRNG}`

Input:

`f()`

simulates Bernoulli(p) random variates (of type Bool)`C >= 0`

`ϵ ∈ (0,1)`

satisfying C*p < 1-ϵ.`[rng]`

the RNG to used by the algorithm (does not affect f)

Output: `X, flips`

`X`

is a Bernoulli(C*p) variate`flips`

is the number of calls of f()

`BernoulliFactory.logistic`

— Method`logistic(f::F, C::Float64, rng::RNG=GLOBAL_RNG) where {F<:Function, RNG<:AbstractRNG}`

Input:

`f()`

simulates Bernoulli(p) random variates (of type Bool)`C >= 0`

`[rng]`

the RNG to used by the algorithm (does not affect f)

Output: `X, flips`

`X`

is a Bernoulli(C*p/(1.0+C*p)) variate`flips`

is the number of calls of f()

`BernoulliFactory.power`

— Method`power(f::F, a::Float64, rng::RNG=GLOBAL_RNG) where {F<:Function, RNG<:AbstractRNG}`

Input:

`f()`

simulates Bernoulli(p) random variates (of type Bool)`a >= 0`

`[rng]`

the RNG to used by the algorithm (does not affect f)

Output: `X, flips`

`X`

is a Bernoulli(p^a) variate`flips`

is the number of calls of f()

`BernoulliFactory.signedEstimate`

— MethodsignedEstimate(μ::F1, φ::F2, a::Float64, b::Float64, δ::Float64, c::Float64, n::Int64, rng::RNG=GLOBAL_RNG) where {F1<:Function, F2<:Function, RNG<:AbstractRNG}

Input:

`μ()`

simulates a random variate X`φ(X)`

is real-valued`a,b,δ,c`

satisfy a <= inf*x φ(x) < b < δ <= μ(φ) < sup*x φ(x) <= c`n`

specifies a number of X variables to average`[rng]`

the RNG to used by the algorithm (does not affect f)

Output: `Y, flips, calls`

`Y`

is almost surely valued in [b, max{2b-a,c}] with E[Y] = μ(φ)`flips`

is the number of coin tosses by the Bernoulli Factory algorithm`calls`

is the number of calls of μ() in total

`BernoulliFactory.signedEstimate`

— MethodsignedEstimate(μ::F1, φ::F2, c::Float64, δ::Float64, n::Int64, rng::RNG=GLOBAL_RNG) where {F1<:Function, F2<:Function, RNG<:AbstractRNG} where {F1<:Function, F2<:Function, RNG<:AbstractRNG}

Input:

`μ()`

simulates a random variate X`φ(X)`

is real-valued`c`

satisfies sup_x |φ(x)| <= c`δ > 0`

satisfies μ(φ) >= δ`n`

specifies a number of X variables to average`[rng]`

the RNG to used by the algorithm (does not affect f)

Output: `Y, flips, calls`

`Y`

is almost surely valued in [0.0,c] with E[Y] = μ(φ)`flips`

is the number of coin tosses by the Bernoulli Factory algorithm`calls`

is the number of calls of μ() in total

`BernoulliFactory.sqrt`

— Method`sqrt(f::F, rng::RNG=GLOBAL_RNG) where {F<:Function, RNG<:AbstractRNG}`

Input:

`f()`

simulates Bernoulli(p) random variates (of type Bool)`[rng]`

the RNG to used by the algorithm (does not affect f)

Output: `X, flips`

`X`

is a Bernoulli(sqrt(p)) variate`flips`

is the number of calls of f()

`BernoulliFactory.twocoin`

— Method`twocoin(f1::F1, f2::F2, C1::Float64, C2::Float64, rng::RNG=GLOBAL_RNG) where {F1<:Function, F2<:Function, RNG<:AbstractRNG}`

Input:

`f1()`

simulates Bernoulli(p1) random variates (of type Bool)`f2()`

simulates Bernoulli(p2) random variates (of type Bool)`C1, C2 >= 0`

`[rng]`

the RNG to used by the algorithm (does not affect f)

Output: `X, flips`

`X`

is a Bernoulli(C1*p1/(C1*p1+C2*p2)) variate`flips`

is the number of calls of f()