Handling infinites in Chi square CDF function properly

This commit is contained in:
Joseph Lizier 2019-05-17 22:24:54 +10:00
parent 8542d217ea
commit 9f9c79bc95
1 changed files with 3 additions and 0 deletions

View File

@ -354,6 +354,9 @@ public class MathsUtils {
if (k <= 0) {
throw new IllegalArgumentException("k (" + k + ") must be > 0");
}
if (Double.isInfinite(x) && (x > 0)) {
return 1.0;
}
// Old approach: (not numerically stable):
// return lowerIncompleteGammaFunctionOfArgsOn2(k,x) /
// gammaOfArgOn2Plus1(k-2); // denominator is Gamma(k/2)