mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-25 22:51:17 +00:00
e88cd615cc
The incomplete gamma primitive used a fixed 32-term power series with no convergence test, so GAMMA.DIST, GAMMADIST, CHISQ.DIST(.RT), GAMMAINV and CHISQ.INV were grossly wrong once the series argument reached ~32 (e.g. CHISQ.DIST.RT(80, 4) returned 0.806 instead of 1.74e-16). Replace it with the standard convergence-tested regularized incomplete gamma: series P(a,x) for x < a+1, continued fraction Q(a,x) for x >= a+1. CHISQ.DIST.RT now uses Q directly so the right tail stays free of 1 - P cancellation. Consolidates the duplicate copy that already existed privately in ChiSquared onto the shared primitive.