Files
gaoflow e88cd615cc Fix incomplete gamma convergence for GAMMA.DIST / CHISQ.DIST
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.
2026-08-04 08:25:36 +02:00

64 lines
864 B
PHP

<?php
declare(strict_types=1);
return [
[
0.964294972685,
3, 9,
],
[
0.4837673815536,
7.5, 8,
],
[
0.050000589092,
18.307, 10,
],
[
0.479500122187,
0.5, 1,
],
[
0.113846298007,
2.5, 1,
],
[
0.778800783071,
0.5, 2,
],
[
0.918891411655,
0.5, 3,
],
[
0.046011705689,
8, 3,
],
// Large x: the old fixed 32-term series diverged badly here.
[
0.177045452100,
70, 60,
],
[
0.064570368921,
100, 80,
],
[
'#VALUE!',
'NaN', 3,
],
[
'#VALUE!',
8, 'NaN',
],
'Value < 0' => [
'#NUM!',
-8, 3,
],
'Degrees < 1' => [
'#NUM!',
8, 0,
],
];