The OpenD Programming Language

poissonPMF

Computes the poisson probability mass function (PMF).

  1. T poissonPMF(size_t k, T lambda)
    template poissonPMF(PoissonAlgo poissonAlgo = PoissonAlgo.direct)
    @safe pure nothrow @nogc
    T
    poissonPMF
    (
    T
    )
    (
    const size_t k
    ,
    const T lambda
    )
    if (
    isFloatingPoint!T
    )
  2. template poissonPMF(string poissonAlgo)

Members

Functions

poissonPMF
T poissonPMF(size_t k, T lambda)

Parameters

poissonAlgo

algorithm for calculating PMF (default: PoissonAlgo.direct)

Examples

import mir.math.common: approxEqual, exp;

assert(3.poissonPMF(6.0).approxEqual(exp(-6.0) * 216 / 6));
// Can compute directly with differences of upper incomplete gamma function
assert(3.poissonPMF!"gamma"(6.0).approxEqual(poissonPMF(3, 6.0)));
// For large values of k or lambda, can approximate with normal distribution
assert(1_000_000.poissonPMF!"approxNormal"(1_000_000.0).approxEqual(poissonPMF!"gamma"(1_000_000, 1_000_000.0), 10e-3));
// Or closer with continuity correction
assert(1_000_000.poissonPMF!"approxNormalContinuityCorrection"(1_000_000.0).approxEqual(poissonPMF!"gamma"(1_000_000, 1_000_000.0), 10e-3));

See Also

Meta