← All changes
|
libraries/vendor/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php
+8
-1
3.3.2
→
3.4
View file →
| @@ -84,8 +84,12 @@ | ||
| 84 | 84 | * GAMMAINV. |
| 85 | 85 | * |
| 86 | 86 | * Returns the inverse of the Gamma distribution. |
| 87 | 87 | * |
| 88 | + * For a probability so far into the upper tail that the forward-CDF series | |
| 89 | + * approximation plateaus below it, the root cannot be bracketed; the result | |
| 90 | + * is capped at the alpha*beta*5 search ceiling rather than diverging. | |
| 91 | + * | |
| 88 | 92 | * @param mixed $probability Float probability at which you want to evaluate the distribution |
| 89 | 93 | * Or can be an array of values |
| 90 | 94 | * @param mixed $alpha Parameter to the distribution as a float |
| 91 | 95 | * Or can be an array of values |
| @@ -142,7 +146,10 @@ | ||
| 142 | 146 | if ($value <= 0) { |
| 143 | 147 | return ExcelError::NAN(); |
| 144 | 148 | } |
| 145 | 149 | |
| 146 | - return log(self::gammaValue($value)); | |
| 150 | + $result = self::logGamma($value); | |
| 151 | + | |
| 152 | + // logGamma returns its MAX_VALUE sentinel when the result would overflow. | |
| 153 | + return ($result >= self::MAX_VALUE) ? ExcelError::NAN() : $result; | |
| 147 | 154 | } |
| 148 | 155 | } |