mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 00:00:43 +00:00
52da37f4a7
GAMMA.INV silently returned the first bisection midpoint for alpha in ~[143, 171.62] (e.g. GAMMA.INV(0.5, 143, 1) gave 358.0 instead of 142.667) and #NUM! above that, because the Newton-step pdf evaluates Gamma(a), b**a and value**(a-1) in linear domain, all of which overflow even though the density itself is a small representable number. The same pattern breaks the GAMMA.DIST, CHISQ.DIST and F.DIST densities and GAMMALN, which computed log(Gamma(x)) through Gamma(x). Evaluate these in log domain via the existing logGamma, and scale the incomplete-gamma series/continued-fraction iteration cap as O(sqrt(a)), which both expansions need to converge near x ~ a once the shape is large (GAMMA.INV drifted from the true quantile above alpha ~5000 and returned alpha+1 by alpha=10000; same for CHISQ.INV at high df).
112 lines
1.9 KiB
PHP
112 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
return [
|
|
[
|
|
0.001223791709,
|
|
15.2069, 6, 4, false,
|
|
],
|
|
[
|
|
0.990000043003,
|
|
15.2069, 6, 4, true,
|
|
],
|
|
[
|
|
0.308000821694,
|
|
1, 2, 5, false,
|
|
],
|
|
[
|
|
0.568798849629,
|
|
1, 2, 5, true,
|
|
],
|
|
[
|
|
0.0241472644208,
|
|
5, 1, 2, false,
|
|
],
|
|
[
|
|
0.8451542547285,
|
|
5, 1, 2, true,
|
|
],
|
|
[
|
|
0.0006669496615,
|
|
65, 2, 1, false,
|
|
],
|
|
[
|
|
0.9126295943339,
|
|
65, 2, 1, true,
|
|
],
|
|
[
|
|
4.7306581130012E-6,
|
|
65, 8, 5, false,
|
|
],
|
|
[
|
|
0.9998747923834,
|
|
65, 8, 5, true,
|
|
],
|
|
[
|
|
0.0017323823929,
|
|
7.5, 13, 8, false,
|
|
],
|
|
[
|
|
0.9961476916638,
|
|
7.5, 13, 8, true,
|
|
],
|
|
[
|
|
'#VALUE!',
|
|
'NAN', 13, 8, true,
|
|
],
|
|
[
|
|
'#VALUE!',
|
|
7.5, 'NAN', 8, true,
|
|
],
|
|
'too many arguments' => [
|
|
'exception',
|
|
7.5, 13, 'NAN', 8, false,
|
|
],
|
|
[
|
|
'#NUM!',
|
|
-7.5, 13, 8, true,
|
|
],
|
|
[
|
|
'#NUM!',
|
|
7.5, 0, 8, true,
|
|
],
|
|
[
|
|
'#NUM!',
|
|
7.5, 13, 0, true,
|
|
],
|
|
// Large degrees of freedom; pdf references from mpmath (50-digit)
|
|
'pdf df=300/300' => [
|
|
3.4520635814271063,
|
|
1, 300, 300, false,
|
|
],
|
|
'pdf df=200/150' => [
|
|
0.056109515617919103,
|
|
1.5, 200, 150, false,
|
|
],
|
|
'pdf df=500/500' => [
|
|
3.63067452308676E-13,
|
|
2, 500, 500, false,
|
|
],
|
|
'pdf df=400/400' => [
|
|
4.68990600023705E-10,
|
|
0.5, 400, 400, false,
|
|
],
|
|
'pdf df=340/1' => [
|
|
0.24161532091192295,
|
|
1, 340, 1, false,
|
|
],
|
|
'pdf at 0, u=1' => [
|
|
'#NUM!',
|
|
0, 1, 5, false,
|
|
],
|
|
'pdf at 0, u=2' => [
|
|
1.0,
|
|
0, 2, 5, false,
|
|
],
|
|
'pdf at 0, u=3' => [
|
|
0.0,
|
|
0, 3, 5, false,
|
|
],
|
|
];
|