value to evaluate PMF (e.g. number of "heads")
number of successes until stopping
true probability
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;
Computes the negative binomial log probability mass function (LPMF).