The OpenD Programming Language

negativeBinomialLPMF

Computes the negative binomial log probability mass function (LPMF).

@safe pure nothrow @nogc
T
negativeBinomialLPMF
(
T
)
(
const size_t k
,
const size_t r
,
const T p
)
if (
isFloatingPoint!T
)

Parameters

k size_t

value to evaluate PMF (e.g. number of "heads")

r size_t

number of successes until stopping

p T

true probability

Examples

import mir.math.common: exp;
import mir.test: shouldApprox;

4.negativeBinomialLPMF(6, 3.0 / 4).exp.shouldApprox == 4.negativeBinomialPMF(6, 3.0 / 4);

Accurate values for large values of n

import mir.bignum.fp: Fp, fp_log;
import mir.test: shouldApprox;

enum size_t val = 1_000_000;

1.negativeBinomialLPMF(1_000_000, 0.75).shouldApprox == fp_negativeBinomialPMF(1, 1_000_000, Fp!128(0.75)).fp_log!double;

See Also

Meta