Skip to main content

binomial_coefficient_f64

Function binomial_coefficient_f64 

Source
pub fn binomial_coefficient_f64(n: usize, k: usize) -> f64
Expand description

Numerically stable C(n,k) = n! / (k!·(n−k)!) as f64. The implementation now lives in the lowest crate (gam-math) so the terms/basis cluster can consume it without reaching up into inference; re-exported here to keep crate::probability::binomial_coefficient_f64 resolving for all existing callers. Numerically stable C(n,k) = n! / (k!·(n−k)!) as f64. Uses the symmetry C(n,k) = C(n, n−k) to keep the loop count min(k, n−k) and the multiplicative recurrence C(n,j+1) = C(n,j)·(n−j)/(j+1), avoiding the overflow of separate factorial evaluations. Returns 0.0 for k > n and exact integer results within 2^53.