Math Utility Functions (Distributions)

Collection of numerical distribution functions (normal, χ², t, F) — the foundation of all hypothesis tests.

Statusvalidated
Version1.0.0

Description

math-utils.js bundles the numerical primitives that every downstream engine relies on: error function (erf), log-gamma, normal CDF/quantile (Abramowitz & Stegun 7.1.26 with corrected scaling), χ² CDF/inverse (regularised incomplete gamma), t CDF/inverse (regularised incomplete beta), F CDF/p-value/quantile. The evaluate(inputs) dispatcher takes a {function, ...args} object and returns {result}, so every function can be validated against SciPy fixtures. The 'validated' status refers to that fixture suite — it was introduced after the normalCDF bug (A&S 7.1.26 argument-scaling error) and protects against regressions.

Formulas

erf
Gaussian error function (Abramowitz & Stegun 7.1.26)
normalCDF
Cumulative normal distribution
normalQuantile
Inverse standard normal distribution
lnGamma
Logarithm of the gamma function
chi2CDF
χ² distribution via the regularised incomplete gamma function
tCDF
Student-t CDF via the regularised incomplete beta function
fCDF
F distribution via the regularised incomplete beta function

Assumptions

  • Arguments lie within each function's valid domain (e.g. df > 0, 0 ≤ p ≤ 1)

Limitations

  • Relative accuracy of the approximations is ~1e-10 to 1e-12 — sufficient for every use case in DMAIC.io, but not bit-identical to SciPy
  • fQuantile and chi2Inv/tInv use bisection — not suitable for extreme tail probabilities (p < 1e-10 or p > 1 − 1e-10)

References

  • Abramowitz & Stegun, Handbook of Mathematical Functions — Ch. 7 (erf), Ch. 26 (Normal CDF)
  • Press, Teukolsky, Vetterling, Flannery — Numerical Recipes, 3rd Ed.
  • Lanczos, C. (1964), A Precision Approximation of the Gamma Function