The OpenD Programming Language

binomialCCDF

Computes the binomial complementary cumulative distribution function (CCDF).

Additional algorithms may be provided for calculating CCDF that allow trading off time and accuracy. If approxPoisson is provided, the default is PoissonAlgo.gamma

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

Members

Functions

binomialCCDF
T binomialCCDF(size_t k, size_t n, T p)

Parameters

binomialAlgo

algorithm for calculating CCDF (default: BinomialAlgo.direct)

poissonAlgo

algorithm for poisson approximation (default: PoissonAlgo.gamma)

Examples

import mir.math.common: approxEqual, pow;

assert(4.binomialCCDF(6, 2.0 / 3).approxEqual(binomialPMF(5, 6, 2.0 / 3) + binomialPMF(6, 6, 2.0 / 3)));
// For large values of `n` with `p` not too extreme, can approximate with normal distribution
assert(550_000.binomialCCDF!"approxNormal"(1_000_000, 0.55).approxEqual(0.5));
// Or closer with continuity correction
assert(550_000.binomialCCDF!"approxNormalContinuityCorrection"(1_000_000, 0.55).approxEqual(0.499599));
// Poisson approximation is better when `p` is low
assert(10_000.binomialCCDF!"approxPoisson"(1_000_000, 0.01).approxEqual(0.4973404));

See Also

Meta