EnumeratedRealDistribution extends AbstractRealDistribution { public double getNumericalVariance() { double mean = 0; double meanOfSquares = 0; for (final Pair<Double, Double> sample : innerDistribution.getPmf()) { mean += sample.getValue() * sample.getKey(); meanOfSquares += sample.getValue() * sample.getKey() * sample.getKey(); } return meanOfSquares - mean * mean; } 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 testGetNumericalVariance() { Assert.assertEquals(7.84, testDistribution.getNumericalVariance(), 1e-10); }