BernoulliFactory.expMinus
— MethodexpMinus(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)) variateflips
is the number of calls of f()
BernoulliFactory.inverse
— Methodinverse(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) variateflips
is the number of calls of f()
BernoulliFactory.linear
— Methodlinear(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) variateflips
is the number of calls of f()
BernoulliFactory.logistic
— Methodlogistic(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(Cp/(1.0+Cp)) variateflips
is the number of calls of f()
BernoulliFactory.power
— Methodpower(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) variateflips
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-valueda,b,δ,c
satisfy a <= infx φ(x) < b < δ <= μ(φ) < supx φ(x) <= cn
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 algorithmcalls
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-valuedc
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 algorithmcalls
is the number of calls of μ() in total
BernoulliFactory.sqrt
— Methodsqrt(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)) variateflips
is the number of calls of f()
BernoulliFactory.twocoin
— Methodtwocoin(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(C1p1/(C1p1+C2*p2)) variateflips
is the number of calls of f()