algorithm for calculating CCDF (default: BinomialAlgo.direct)
algorithm for poisson approximation (default: PoissonAlgo.gamma)
import mir.math.common: approxEqual, pow; assert(4.binomialCCDF(6, 2.0 / 3).approxEqual(binomialPMF(5, 6, 2.0 / 3) + binomialPMF(6, 6, 2.0 / 3))); // For large values of `n` with `p` not too extreme, can approximate with normal distribution assert(550_000.binomialCCDF!"approxNormal"(1_000_000, 0.55).approxEqual(0.5)); // Or closer with continuity correction assert(550_000.binomialCCDF!"approxNormalContinuityCorrection"(1_000_000, 0.55).approxEqual(0.499599)); // Poisson approximation is better when `p` is low assert(10_000.binomialCCDF!"approxPoisson"(1_000_000, 0.01).approxEqual(0.4973404));
Computes the binomial complementary cumulative distribution function (CCDF).
Additional algorithms may be provided for calculating CCDF that allow trading off time and accuracy. If approxPoisson is provided, the default is PoissonAlgo.gamma