The OpenD Programming Language

binomialInvCDF

Computes the binomial inverse cumulative distribution function (InvCDF).

Additional algorithms may be provided for calculating InvCDF that allow trading off time and accuracy. If approxPoisson is provided, the default is PoissonAlgo.direct, which is different from binomialPMF and binomialCDF PoissonAlgo.gamma is not supported.

  1. size_t binomialInvCDF(T q, size_t n, T p)
    template binomialInvCDF(BinomialAlgo binomialAlgo = BinomialAlgo.direct, PoissonAlgo poissonAlgo = PoissonAlgo.direct)
    @safe pure nothrow @nogc
    size_t
    binomialInvCDF
    (
    T
    )
    (
    const T q
    ,
    const size_t n
    ,
    const T p
    )
    if (
    isFloatingPoint!T
    )
    if (
    poissonAlgo != PoissonAlgo.gamma
    )
  2. template binomialInvCDF(string binomialAlgo, string poissonAlgo = "direct")

Members

Functions

binomialInvCDF
size_t binomialInvCDF(T q, size_t n, T p)

Parameters

binomialAlgo

algorithm for calculating CDF (default: BinomialAlgo.direct)

poissonAlgo

algorithm for poisson approximation (default: PoissonAlgo.direct)

Examples

assert(0.15.binomialInvCDF(6, 2.0 / 3) == 3);
// For large values of `n` with `p` not too extreme, can approximate with normal distribution
assert(0.5.binomialInvCDF!"approxNormal"(1_000_000, 0.55) == 550_000);
// Or closer with continuity correction
assert(0.500401.binomialInvCDF!"approxNormalContinuityCorrection"(1_000_000, 0.55) == 550_000);
// Poisson approximation is better when `p` is low
assert(0.5026596.binomialInvCDF!"approxPoisson"(1_000_000, 0.01) == 10_000);

See Also

Meta