Mean extends AbstractStorelessUnivariateStatistic implements Serializable, WeightedEvaluation { @Override public double evaluate(final double[] values,final int begin, final int length) throws MathIllegalArgumentException { if (test(values, begin, length)) { Sum sum = new Sum(); double sampleSize = length; double xbar = sum.evaluate(values, begin, length) / sampleSize; double correction = 0; for (int i = begin; i < begin + length; i++) { correction += values[i] - xbar; } return xbar + (correction/sampleSize); } return Double.NaN; } Mean();  Mean(final FirstMoment m1);  Mean(Mean original); @Override void increment(final double d); @Override void clear(); @Override double getResult(); long getN(); @Override double evaluate(final double[] values,final int begin, final int length); double evaluate(final double[] values, final double[] weights,
                           final int begin, final int length); double evaluate(final double[] values, final double[] weights); @Override Mean copy(); static void copy(Mean source, Mean dest);  }
@Test public void testWeightedMean() { Mean mean = new Mean(); Assert.assertEquals(expectedWeightedValue(), mean.evaluate(testArray, testWeightsArray, 0, testArray.length), getTolerance()); Assert.assertEquals(expectedValue(), mean.evaluate(testArray, identicalWeightsArray, 0, testArray.length), getTolerance()); }