@Test
 public void testSummaryConsistency() {
   final DescriptiveStatistics dstats = new DescriptiveStatistics();
   final SummaryStatistics sstats = new SummaryStatistics();
   final int windowSize = 5;
   dstats.setWindowSize(windowSize);
   final double tol = 1E-12;
   for (int i = 0; i < 20; i++) {
     dstats.addValue(i);
     sstats.clear();
     double[] values = dstats.getValues();
     for (int j = 0; j < values.length; j++) {
       sstats.addValue(values[j]);
     }
     TestUtils.assertEquals(dstats.getMean(), sstats.getMean(), tol);
     TestUtils.assertEquals(new Mean().evaluate(values), dstats.getMean(), tol);
     TestUtils.assertEquals(dstats.getMax(), sstats.getMax(), tol);
     TestUtils.assertEquals(new Max().evaluate(values), dstats.getMax(), tol);
     TestUtils.assertEquals(dstats.getGeometricMean(), sstats.getGeometricMean(), tol);
     TestUtils.assertEquals(new GeometricMean().evaluate(values), dstats.getGeometricMean(), tol);
     TestUtils.assertEquals(dstats.getMin(), sstats.getMin(), tol);
     TestUtils.assertEquals(new Min().evaluate(values), dstats.getMin(), tol);
     TestUtils.assertEquals(dstats.getStandardDeviation(), sstats.getStandardDeviation(), tol);
     TestUtils.assertEquals(dstats.getVariance(), sstats.getVariance(), tol);
     TestUtils.assertEquals(new Variance().evaluate(values), dstats.getVariance(), tol);
     TestUtils.assertEquals(dstats.getSum(), sstats.getSum(), tol);
     TestUtils.assertEquals(new Sum().evaluate(values), dstats.getSum(), tol);
     TestUtils.assertEquals(dstats.getSumsq(), sstats.getSumsq(), tol);
     TestUtils.assertEquals(new SumOfSquares().evaluate(values), dstats.getSumsq(), tol);
     TestUtils.assertEquals(dstats.getPopulationVariance(), sstats.getPopulationVariance(), tol);
     TestUtils.assertEquals(
         new Variance(false).evaluate(values), dstats.getPopulationVariance(), tol);
   }
 }
 @Test
 public void testGetValues() {
   DescriptiveStatistics stats = createDescriptiveStatistics();
   for (int i = 100; i > 0; --i) {
     stats.addValue(i);
   }
   int refSum = (100 * 101) / 2;
   Assert.assertEquals(refSum / 100.0, stats.getMean(), 1E-10);
   double[] v = stats.getValues();
   for (int i = 0; i < v.length; ++i) {
     Assert.assertEquals(100.0 - i, v[i], 1.0e-10);
   }
   double[] s = stats.getSortedValues();
   for (int i = 0; i < s.length; ++i) {
     Assert.assertEquals(i + 1.0, s[i], 1.0e-10);
   }
   Assert.assertEquals(12.0, stats.getElement(88), 1.0e-10);
 }