NormalDistribution extends AbstractRealDistribution { public double cumulativeProbability(double x) { final double dev = x - mean; if (FastMath.abs(dev) > 40 * standardDeviation) { return dev < 0 ? 0.0d : 1.0d; } return 0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2))); } NormalDistribution();  NormalDistribution(double mean, double sd);  NormalDistribution(double mean, double sd, double inverseCumAccuracy);  NormalDistribution(RandomGenerator rng, double mean, double sd);  NormalDistribution(RandomGenerator rng,
                              double mean,
                              double sd,
                              double inverseCumAccuracy); double getMean(); double getStandardDeviation(); double density(double x); @Override double logDensity(double x); double cumulativeProbability(double x); @Override double inverseCumulativeProbability(final double p); @Override@Deprecated double cumulativeProbability(double x0, double x1); @Override double probability(double x0,
                              double x1); double getNumericalMean(); double getNumericalVariance(); double getSupportLowerBound(); double getSupportUpperBound(); boolean isSupportLowerBoundInclusive(); boolean isSupportUpperBoundInclusive(); boolean isSupportConnected(); @Override double sample(); static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY; }
@Test public void testExtremeValues() { NormalDistribution distribution = new NormalDistribution(0, 1); for (int i = 0; i < 100; i++) { double lowerTail = distribution.cumulativeProbability(-i); double upperTail = distribution.cumulativeProbability(i); if (i < 9) { Assert.assertTrue(lowerTail > 0.0d); Assert.assertTrue(upperTail < 1.0d); } else { Assert.assertTrue(lowerTail < 0.00001); Assert.assertTrue(upperTail > 0.99999); } } Assert.assertEquals(distribution.cumulativeProbability(Double.MAX_VALUE), 1, 0); Assert.assertEquals(distribution.cumulativeProbability(-Double.MAX_VALUE), 0, 0); Assert.assertEquals(distribution.cumulativeProbability(Double.POSITIVE_INFINITY), 1, 0); Assert.assertEquals(distribution.cumulativeProbability(Double.NEGATIVE_INFINITY), 0, 0); }