EnumeratedRealDistribution extends AbstractRealDistribution { public double cumulativeProbability(final double x) { double probability = 0; for (final Pair<Double, Double> sample : innerDistribution.getPmf()) { if (sample.getKey() <= x) { probability += sample.getValue(); } } return probability; } EnumeratedRealDistribution(final double[] singletons, final double[] probabilities);  EnumeratedRealDistribution(final RandomGenerator rng,
                                    final double[] singletons, final double[] probabilities); @Override double probability(final double x); double density(final double x); double cumulativeProbability(final double x); @Override double inverseCumulativeProbability(final double p); double getNumericalMean(); double getNumericalVariance(); double getSupportLowerBound(); double getSupportUpperBound(); boolean isSupportLowerBoundInclusive(); boolean isSupportUpperBoundInclusive(); boolean isSupportConnected(); @Override double sample();  }
@Test public void testCumulativeProbability() { double[] points = new double[]{-2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}; double[] results = new double[]{0, 0.2, 0.2, 0.2, 0.2, 0.7, 0.7, 0.7, 0.7, 1.0, 1.0}; for (int p = 0; p < points.length; p++) { double probability = testDistribution.cumulativeProbability(points[p]); Assert.assertEquals(results[p], probability, 1e-10); } }