Expand description
Special functions implemented in-crate rather than pulled from a dependency.
MBA-1347 needs the mass of a bivariate normal over a target rectangle/circle, which
comes down to evaluating the standard normal CDF (and therefore the error function).
The crate ships to thirteen platforms including big-endian MIPS, RISC-V and wasm32
and is deliberately dependency-light โ it already hand-rolls its statistical
constants elsewhere โ so erf/erfc/normal_cdf are implemented and tested here
instead of pulling in a crate like libm or statrs.
ln_gamma and ln_beta were added for Plan C (MBA-1352): the beta-binomial
mixture confidence sequence needs the log gamma and log beta functions, and the
same dependency-light posture applies โ implemented and tested here rather than
pulled in from libm or statrs.
There are two independent approximations to validate: erfc, of which erf and
normal_cdf are thin wrappers computed directly rather than as 1.0 - erf(...) so evaluating deep in a tail never cancels away the answer; and
ln_gamma (Lanczos, g = 7), of which ln_beta is in turn a thin wrapper.
Functionsยง
- erf
- Error function:
erf(x) = 2/sqrt(pi) * integral_0^x exp(-t^2) dt. - erfc
- Complementary error function,
erfc(x) = 1 - erf(x). - ln_beta
- ln B(a, b) = ln Gamma(a) + ln Gamma(b) - ln Gamma(a + b), same domain rule per argument.
- ln_
gamma - Natural log of the gamma function on the positive reals.
- normal_
cdf - Standard normal (mean 0, variance 1) cumulative distribution function:
P(Z <= z).