Skip to main content

Module mathfn

Module mathfn 

Source
Expand description

Special functions and probability distributions implemented from scratch.

The implementation follows the standard series and continued-fraction methods for the regularized incomplete gamma and beta functions (Numerical Recipes style, with explicit iteration bounds and a structured NonConvergence error). No statrs or platform erf is used; on wasm32 every transcendental falls back to libm.

Functionsยง

abs
beta_cdf
beta_pdf
beta_quantile
beta_sf
Upper tail P(X > x), computed from the mirrored regularized incomplete beta function rather than 1 - cdf.
binomial_cdf
binomial_pmf
chi_square_cdf
chi_square_pdf
chi_square_quantile
chi_square_sf
erf
Error function, computed from the regularized incomplete gamma: erf(x) = P(1/2, x^2) for x >= 0.
erfc
Complementary error function, computed from the regularized upper incomplete gamma so that the positive tail keeps full relative accuracy.
exp
exponential_cdf
exponential_pdf
exponential_quantile
exponential_sf
Upper tail P(X > x) computed from exp directly so large x keeps relative accuracy (never 1 - cdf).
f_cdf
f_pdf
f_quantile
f_sf
Upper tail P(X > x), computed directly from the regularized incomplete beta function so large x keeps relative accuracy.
gamma_cdf
gamma_p
Regularized lower incomplete gamma P(a, x).
gamma_pdf
gamma_q
Regularized upper incomplete gamma Q(a, x).
gamma_quantile
ibeta
Regularized incomplete beta I_x(a, b).
invert_monotone
Invert a strictly increasing CDF by bracket expansion, bisection, and Newton polishing. The tolerance is relative (1e-15), comfortably inside the documented 1e-12 requirement.
lgamma
Lanczos approximation to ln|Gamma(x)|.
ln
lognormal_cdf
lognormal_pdf
lognormal_quantile
negative_binomial_cdf
negative_binomial_pmf
normal_cdf
normal_pdf
normal_quantile
normal_sf
Upper tail P(X > x), computed with erfc so large positive x keeps relative accuracy (never 1 - cdf).
poisson_cdf
poisson_pmf
sin
sqrt
student_t_cdf
student_t_pdf
student_t_quantile
student_t_sf
uniform_cdf
uniform_pdf
uniform_quantile