Skip to main content

negative_binomial_quantile

Function negative_binomial_quantile 

Source
pub fn negative_binomial_quantile(p: f64, mu: f64, theta: f64) -> f64
Expand description

Quantile (inverse CDF) of a Negative-Binomial with mean μ ≥ 0 and dispersion θ > 0 at probability p ∈ (0, 1): the smallest integer count k ≥ 0 with P(Y ≤ k) ≥ p, returned as an f64.

p ≤ 0 maps to the 0 support floor and p ≥ 1 to +∞; a non-finite or non-positive dispersion, or a non-finite / negative mean, yields NaN; a zero mean is the degenerate point mass at 0.

Unlike the continuous Gamma/Beta quantiles, the NB is discrete with a real atom at zero, so its skew-correct predictive band must come from the genuine integer quantiles — a moment-matched continuous surrogate (e.g. a Gamma) has no zero atom and grossly over-covers the lower tail on low-mean counts (#1193). A normal-approximation seed brackets the root, then an exact bisection on the incomplete-beta CDF finds the smallest qualifying integer.