Statistics { public abstract Object getResult();  abstract void addSample(double sample); abstract Object getResult(); abstract Long getNumSamples(); final static String STATS_PROPERTY; }
@Test public void testMeanAndSum() { double mean = 0; double sum = calculateSumMean(sumObj, meanObj); double sum2 = (Double) (sumObj.getResult()); assertEquals(sum, sum2, TOLERANCE); mean = sum / (ARRAY_DIMENSIONS - 1); double mean2 = (Double) (meanObj.getResult()); assertEquals(mean, mean2, TOLERANCE); }
@Test public void testMinMaxExtrema() { double[] minMax = calculateMaxMinExtrema(minObj, maxObj, extremaObj); double min = minMax[0]; double max = minMax[1]; double[] array = (double[]) (extremaObj.getResult()); double max2 = array[1]; double min2 = array[0]; assertEquals(min, min2, TOLERANCE); assertEquals(max, max2, TOLERANCE); double min3 = (Double) (minObj.getResult()); assertEquals(min, min3, TOLERANCE); double max3 = (Double) (maxObj.getResult()); assertEquals(max, max3, TOLERANCE); }
@Test public void testDevStdVariance() { double mean = 0; double variance = 0; double std = 0; double sum = calculateVarianceAndStd(varianceObj, devstdObj); mean = sum / (ARRAY_DIMENSIONS - 1); double sum2 = 0; for (int i = 0; i < ARRAY_DIMENSIONS; i++) { sum2 += Math.pow((testArray[i] - mean), 2); } variance = sum2 / (ARRAY_DIMENSIONS - 1); double variance2 = (Double) (varianceObj.getResult()); assertEquals(variance, variance2, TOLERANCE); std = Math.sqrt(variance); double std2 = (Double) (devstdObj.getResult()); assertEquals(std, std2, TOLERANCE); }