EnumeratedIntegerDistribution extends AbstractIntegerDistribution { @Override public int sample() { return innerDistribution.sample(); } 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 testSample() { final int n = 1000000; testDistribution.reseedRandomGenerator(-334759360); final int[] samples = testDistribution.sample(n); Assert.assertEquals(n, samples.length); double sum = 0; double sumOfSquares = 0; for (int i = 0; i < samples.length; i++) { sum += samples[i]; sumOfSquares += samples[i] * samples[i]; } Assert.assertEquals(testDistribution.getNumericalMean(), sum / n, 1e-2); Assert.assertEquals(testDistribution.getNumericalVariance(), sumOfSquares / n - FastMath.pow(sum / n, 2), 1e-2); }