@Test public void testConstructors() { VariableStatistics vs1 = new VariableStatistics(); Assert.assertEquals(vs1.getCount(), 0); Assert.assertEquals(vs1.getSum(), 0, TOLERANCE); Assert.assertEquals(vs1.getSumSquares(), 0, TOLERANCE); VariableStatistics set1 = getVS1(); VariableStatistics set2 = getVS1(); Assert.assertTrue(set1.equivalent(set2)); Assert.assertFalse(set1.equivalent(vs1)); Assert.assertEquals(set1.getCount(), DATA_SET_SIZE); Assert.assertEquals(set1.getSum(), 30, TOLERANCE); Assert.assertEquals(set1.getSumSquares(), 166, TOLERANCE); Assert.assertEquals(set1.getMean(), 5, TOLERANCE); double stdev = set1.getStandardDeviation(); Assert.assertEquals(stdev, 1.63299, TOLERANCE); set2 = getVS2(); Assert.assertEquals(set2.getCount(), DATA_SET_SIZE); Assert.assertEquals(set2.getSum(), 30, TOLERANCE); Assert.assertEquals(set2.getSumSquares(), 216, TOLERANCE); Assert.assertEquals(set2.getMean(), 5, TOLERANCE); stdev = set2.getStandardDeviation(); Assert.assertEquals(stdev, 3.3166, TOLERANCE); }
@Test public void testStrings() { VariableStatistics set1 = getVS1(); String s = set1.toString(); VariableStatistics set2 = new VariableStatistics(s); Assert.assertTrue(set1.equivalent(set2)); }