Expand description
Scalar special-function primitives shared across the workspace.
These are pure (std/libm-only) numeric kernels with no upward crate
dependencies, so they live in the lowest crate (gam-math) and can be
consumed by any term/basis/inference code without inducing an SCC edge.
Functions§
- binomial_
coefficient_ f64 - Numerically stable
C(n,k) = n! / (k!·(n−k)!)asf64. Uses the symmetryC(n,k) = C(n, n−k)to keep the loop countmin(k, n−k)and the multiplicative recurrenceC(n,j+1) = C(n,j)·(n−j)/(j+1), avoiding the overflow of separate factorial evaluations. Returns0.0fork > nand exact integer results within2^53. - stable_
polynomial_ times_ exp_ neg - Evaluate
(Σ_k coeffs[k]·x^k) · exp(−x)without overflow. For moderatex ≤ 600uses Horner +exp(−x)directly; for very largexrewritesxᵈ · exp(−x) = exp(d·ln x − x)and runs Horner in1/x, which keeps both the polynomial sum and its multiplier inside double range. Returns0.0for non-finitexor emptycoeffs.