u.clear();
assertEquals("total count",0,u.getN(),tolerance);
}
public void testN0andN1Conditions() throws Exception {
StorelessDescriptiveStatisticsImpl u = new StorelessDescriptiveStatisticsImpl();
assertTrue("Mean of n = 0 set should be NaN",
Double.isNaN( u.getMean() ) );
assertTrue("Standard Deviation of n = 0 set should be NaN",
Double.isNaN( u.getStandardDeviation() ) );
assertTrue("Variance of n = 0 set should be NaN",
Double.isNaN(u.getVariance() ) );
assertTrue("skew of n = 0 set should be NaN",
Double.isNaN(u.getSkewness() ) );
assertTrue("kurtosis of n = 0 set should be NaN",
Double.isNaN(u.getKurtosis() ) );
/* n=1 */
u.addValue(one);
assertTrue("mean should be one (n = 1)",
u.getMean() == one);
assertTrue("geometric should be one (n = 1) instead it is " + u.getGeometricMean(),
u.getGeometricMean() == one);
assertTrue("Std should be zero (n = 1)",
u.getStandardDeviation() == 0.0);
assertTrue("variance should be zero (n = 1)",
u.getVariance() == 0.0);
assertTrue("skew should be zero (n = 1)",
u.getSkewness() == 0.0);
assertTrue("kurtosis should be zero (n = 1)",
u.getKurtosis() == 0.0);
/* n=2 */
u.addValue(twoF);
assertTrue("Std should not be zero (n = 2)",
u.getStandardDeviation() != 0.0);
assertTrue("variance should not be zero (n = 2)",
u.getVariance() != 0.0);
assertTrue("skew should not be zero (n = 2)",
u.getSkewness() == 0.0);
assertTrue("kurtosis should be zero (n = 2)",
u.getKurtosis() == 0.0);
/* n=3 */
u.addValue(twoL);
assertTrue("skew should not be zero (n = 3)",
u.getSkewness() != 0.0);
assertTrue("kurtosis should be zero (n = 3)",
u.getKurtosis() == 0.0);
/* n=4 */
u.addValue(three);
assertTrue("kurtosis should not be zero (n = 4)",
u.getKurtosis() != 0.0);
}