EnumeratedIntegerDistribution extends AbstractIntegerDistribution { public double cumulativeProbability(final int x) { double probability = 0; for (final Pair<Integer, Double> sample : innerDistribution.getPmf()) { if (sample.getKey() <= x) { probability += sample.getValue(); } } return probability; } EnumeratedIntegerDistribution(final int[] singletons, final double[] probabilities);  EnumeratedIntegerDistribution(final RandomGenerator rng,
                                       final int[] singletons, final double[] probabilities); double probability(final int x); double cumulativeProbability(final int x); double getNumericalMean(); double getNumericalVariance(); int getSupportLowerBound(); int getSupportUpperBound(); boolean isSupportConnected(); @Override int sample();  }
@Test public void testCumulativeProbability() { int[] points = new int[]{-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8}; 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); } }