The OpenD Programming Language

poissonPMF

Computes the poisson probability mass function (PMF).

  1. template poissonPMF(PoissonAlgo poissonAlgo = PoissonAlgo.direct)
  2. template poissonPMF(string poissonAlgo)
    @safe pure nothrow @nogc
    template poissonPMF (
    string poissonAlgo
    )

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