Changes for version 0.294 - 2026-08-07
- bug fixes: https://www.cpantesters.org/cpan/report/368ca238-73ee-1014-a03f-97f1b88bf904
- `binom_test` was cross-validated against R 4.6.1 `stats::binom.test` and SciPy 1.17.1 `scipy.stats.binomtest` using their own test suites rather than cases invented here: SciPy's `TestBinomTest`, R's `binom.test(c(800,10))` from `tests/reg-tests-2.R`, the `?binom.test` example, and an R-generated corpus of 383 p-values and 1560 Clopper-Pearson bounds. They are in `t/binom_test.R.scipy.t`. Two fixes came out of it, both in the incomplete beta that every tail and confidence bound goes through:
- Its continued fraction stopped after a flat 500 terms, but it needs about 0.25 sqrt(a+b) of them once the shape parameters are large, so it was quietly cut short at big `n`: `binom_test(10079990, 21000000, p => 0.48)` returned 0.996781946606 where R and SciPy both give 0.9966892187965, i.e. wrong in the fourth decimal of a printed p-value. The cap now scales with sqrt(a+b), and the front factor moved off differenced `lgamma` onto the same saddle-point form `dbinom` already used here. Agreement with R over these cases went from 9.3e-5 to 3.3e-13 relative.
- The Clopper-Pearson bounds are found by bisection, which stopped at an absolute width of 1e-15, so a bound far below 1 came back with only four correct digits: `binom_test(1, 1000000000, alternative => 'greater', conf_level => 0.999)` gave 1.00053299e-12 against R's 1.00050033e-12. The stopping rule is now relative to where the bracket sits, and such bounds now hold about 1e-15.
- Both fixes also help `t_test`, `var_test` and `cor_test`, which use the same function. One limit remains, pinned by the tests rather than left to chance: the upper bound for a handful of successes in a billion trials still carries about 1e-9 of relative error, because the complement branch of the incomplete beta cannot resolve a tiny `x` past the spacing of `1-x`.
Modules
Get basic statistical functions, like in R, but with Perl using XS for performance