Sum extends AbstractStorelessUnivariateStatistic implements Serializable { @Override public double evaluate(final double[] values, final int begin, final int length) throws MathIllegalArgumentException { double sum = Double.NaN; if (test(values, begin, length, true)) { sum = 0.0; for (int i = begin; i < begin + length; i++) { sum += values[i]; } } return sum; } Sum();  Sum(Sum original); @Override void increment(final double d); @Override double getResult(); long getN(); @Override void clear(); @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 Sum copy(); static void copy(Sum source, Sum dest);  }
@Test public void testWeightedSum() { Sum sum = new Sum(); Assert.assertEquals(expectedWeightedValue(), sum.evaluate(testArray, testWeightsArray, 0, testArray.length), getTolerance()); Assert.assertEquals(expectedValue(), sum.evaluate(testArray, unitWeightsArray, 0, testArray.length), getTolerance()); }