The OpenD Programming Language

fp_hypergeometricPMF

Computes the hypergeometric probability mass function (PMF) with extended floating point types (e.g. Fp!128), which provides additional accuracy for large values of k, N, K, or n.

@safe pure @nogc nothrow
T
fp_hypergeometricPMF
(
T = Fp!128
)
(
const size_t k
,
const size_t N
,
const size_t K
,
const size_t n
)
if (
is(T == Fp!size,
size_t size
)
)

Parameters

k size_t

value to evaluate PMF (e.g. number of correct draws of object of interest)

N size_t

total population size

K size_t

number of relevant objects in population

n size_t

number of draws

Examples

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

enum size_t val = 1_000_000;
size_t N = val + 5;
size_t K = val / 2;
size_t n = val / 100;
0.fp_hypergeometricPMF(N, K, n).fp_log!double.shouldApprox == hypergeometricLPMF(0, N, K, n);
1.fp_hypergeometricPMF(N, K, n).fp_log!double.shouldApprox == hypergeometricLPMF(1, N, K, n);
2.fp_hypergeometricPMF(N, K, n).fp_log!double.shouldApprox == hypergeometricLPMF(2, N, K, n);
5.fp_hypergeometricPMF(N, K, n).fp_log!double.shouldApprox == hypergeometricLPMF(5, N, K, n);
(n / 2).fp_hypergeometricPMF(N, K, n).fp_log!double.shouldApprox == hypergeometricLPMF(n / 2, N, K, n);
(n - 5).fp_hypergeometricPMF(N, K, n).fp_log!double.shouldApprox == hypergeometricLPMF(n - 5, N, K, n);
(n - 2).fp_hypergeometricPMF(N, K, n).fp_log!double.shouldApprox == hypergeometricLPMF(n - 2, N, K, n);
(n - 1).fp_hypergeometricPMF(N, K, n).fp_log!double.shouldApprox == hypergeometricLPMF(n - 1, N, K, n);
n.fp_hypergeometricPMF(N, K, n).fp_log!double.shouldApprox == hypergeometricLPMF(n, N, K, n);

See Also

Meta