### Question:
NonCentralChiSquaredDistribution implements ProbabilityDistribution<Double> { @Override public double getCDF(Double x) { ArgChecker.notNull(x, "x"); if (x < 0) { return 0.0; } if ((_dofOverTwo + _lambdaOverTwo) > 1000) { return getFraserApproxCDF(x); } double regGammaStart = 0; double halfX = x / 2.0; double logX = Math.log(halfX); try { regGammaStart = Gamma.regularizedGammaP(_dofOverTwo + _k, halfX); } catch (MaxCountExceededException ex) { throw new MathException(ex); } double sum = _pStart * regGammaStart; double oldSum = Double.NEGATIVE_INFINITY; double p = _pStart; double regGamma = regGammaStart; double temp; int i = _k; while (i > 0 && Math.abs(sum - oldSum) / sum > _eps) { i--; p *= (i + 1) / _lambdaOverTwo; temp = (_dofOverTwo + i) * logX - halfX - Gamma.logGamma(_dofOverTwo + i + 1); regGamma += Math.exp(temp); oldSum = sum; sum += p * regGamma; } p = _pStart; regGamma = regGammaStart; oldSum = Double.NEGATIVE_INFINITY; i = _k; while (Math.abs(sum - oldSum) / sum > _eps) { i++; p *= _lambdaOverTwo / i; temp = (_dofOverTwo + i - 1) * logX - halfX - Gamma.logGamma(_dofOverTwo + i); regGamma -= Math.exp(temp); oldSum = sum; sum += p * regGamma; } return sum; } NonCentralChiSquaredDistribution(double degrees, double nonCentrality); @Override double getCDF(Double x); @Override double getInverseCDF(Double p); @Override double getPDF(Double x); @Override double nextRandom(); double getDegrees(); double getNonCentrality(); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test public void testNullX() { assertThatIllegalArgumentException() .isThrownBy(() -> DIST.getCDF(null)); }
@Test public void testLargeValues() { double x = 123; double dof = 6.4; double nonCent = 100.34; NonCentralChiSquaredDistribution dist = new NonCentralChiSquaredDistribution(dof, nonCent); assertThat(0.7930769).isCloseTo(dist.getCDF(x), offset(1e-6)); x = 455.038; dof = 12; nonCent = 444.44; dist = new NonCentralChiSquaredDistribution(dof, nonCent); assertThat(0.4961805).isCloseTo(dist.getCDF(x), offset(1e-6)); x = 999400; dof = 500; nonCent = 1000000; dist = new NonCentralChiSquaredDistribution(dof, nonCent); assertThat(0.2913029).isCloseTo(dist.getCDF(x), offset(1e-6)); }
@Test public void debugTest() { final double dof = 3.666; final double nonCentrality = 75; final double x = 13.89; final NonCentralChiSquaredDistribution chiSq1 = new NonCentralChiSquaredDistribution(dof, nonCentrality); final double y1 = Math.log(chiSq1.getCDF(x)); assertThat(-15.92129).isCloseTo(y1, offset(1e-5)); }