Esempio n. 1
0
 /** Test of add method, of class Statistics. */
 @Test
 public strictfp void testAdd_double() {
   ListStatistics stats = new ListStatistics();
   stats.addValue(VALUES[0]);
   assertEquals(1, stats.getN());
   assertEquals(VALUES[0], stats.getSum(), 0.0);
   assertEquals(VALUES[0], stats.getMax(), 0.0);
   assertEquals(VALUES[0], stats.getMin(), 0.0);
   assertEquals(VALUES[0], stats.getMean(), 0.0);
   assertEquals(Double.NaN, stats.getVariance(), 0.0);
   assertEquals(Double.NaN, stats.getStandardDeviation(), 0.0);
 }
Esempio n. 2
0
 /** Test of toString, of class Statistics */
 @Test
 public strictfp void testToString() {
   String expResult =
       "N:25 Mean: 51.03316951740001 Min: 2.34517545 Max: 96.66786311 StdDev: 28.582874479178013";
   String result = instance.toString();
   assertEquals(expResult, result);
 }
Esempio n. 3
0
  @Test
  public strictfp void testSignificant_Never() {
    ListStatistics s1 = new ListStatistics();
    ListStatistics s2 = new ListStatistics();

    for (int c = 0; c < 10; c++) {
      s1.addValue(1);
      s1.addValue(1.1);
      s2.addValue(1);
      s2.addValue(1.1);
    }

    for (double conf : new double[] {0.5, 0.9, 0.99, 0.999, 0.9999, 0.99999}) {
      Assert.assertFalse("Diff not significant at " + conf, s1.isDifferent(s2, conf));
      Assert.assertEquals(0, s1.compareTo(s2, conf));
    }
  }
Esempio n. 4
0
 /** Test of getMax method, of class Statistics. */
 @Test
 public strictfp void testGetMax() {
   assertEquals(96.66786311, instance.getMax(), 0.0);
 }
Esempio n. 5
0
 /** Test of getMean method, of class Statistics. */
 @Test
 public strictfp void testGetMean() {
   assertEquals(51.033, instance.getMean(), 0.001);
 }
Esempio n. 6
0
 /** Test of getSum method, of class Statistics. */
 @Test
 public strictfp void testGetSum() {
   assertEquals(1275.829, instance.getSum(), 0.001);
 }
Esempio n. 7
0
 /** Test of getN method, of class Statistics. */
 @Test
 public strictfp void testGetN() {
   assertEquals((long) VALUES.length, instance.getN());
 }
Esempio n. 8
0
 @BeforeClass
 public static void setUpClass() throws Exception {
   for (double value : VALUES) {
     instance.addValue(value);
   }
 }
Esempio n. 9
0
 /** Test of getConfidenceIntervalAt, of class Statistics */
 @Test
 public strictfp void testGetConfidenceInterval() {
   double[] interval = instance.getConfidenceIntervalAt(0.999);
   assertEquals(29.62232, interval[0], 0.002);
   assertEquals(72.44402, interval[1], 0.002);
 }
Esempio n. 10
0
  @Test
  public strictfp void testSignificant_Sometimes() {
    ListStatistics s1 = new ListStatistics();
    ListStatistics s2 = new ListStatistics();

    for (int c = 0; c < 10; c++) {
      s1.addValue(1);
      s1.addValue(2);
      s2.addValue(1);
      s2.addValue(3);
    }

    Assert.assertTrue("Diff significant at 0.5", s1.isDifferent(s2, 0.5));
    Assert.assertTrue("Diff significant at 0.9", s1.isDifferent(s2, 0.9));
    Assert.assertFalse("Diff not significant at 0.99", s1.isDifferent(s2, 0.99));
    Assert.assertFalse("Diff not significant at 0.999", s1.isDifferent(s2, 0.999));
    Assert.assertFalse("Diff not significant at 0.9999", s1.isDifferent(s2, 0.9999));

    Assert.assertEquals("compareTo at 0.5", 1, s1.compareTo(s2, 0.5));
    Assert.assertEquals("compareTo at 0.9", 1, s1.compareTo(s2, 0.9));
    Assert.assertEquals("compareTo at 0.99", 0, s1.compareTo(s2, 0.99));
    Assert.assertEquals("compareTo at 0.999", 0, s1.compareTo(s2, 0.999));
    Assert.assertEquals("compareTo at 0.9999", 0, s1.compareTo(s2, 0.9999));
  }
Esempio n. 11
0
 @Test
 public strictfp void testPercentile_100() {
   assertEquals(96.667, instance.getPercentile(100), 0.002);
 }
Esempio n. 12
0
 @Test
 public strictfp void testPercentile_90() {
   assertEquals(93.044, instance.getPercentile(90), 0.002);
 }
Esempio n. 13
0
 @Test
 public strictfp void testPercentile_50() {
   assertEquals(56.460, instance.getPercentile(50), 0.002);
 }
Esempio n. 14
0
 @Test
 public strictfp void testPercentile_00() {
   assertEquals(2.345, instance.getPercentile(0), 0.002);
 }
Esempio n. 15
0
 /** Test of getMin method, of class Statistics. */
 @Test
 public strictfp void testGetMin() {
   assertEquals(2.34517545, instance.getMin(), 0.0);
 }
Esempio n. 16
0
  @Test
  public strictfp void testSingle() {
    ListStatistics s = new ListStatistics();
    s.addValue(42.0D);

    Assert.assertEquals(1, s.getN());
    Assert.assertEquals(42.0D, s.getSum());
    Assert.assertEquals(42.0D, s.getMin());
    Assert.assertEquals(42.0D, s.getMax());
    Assert.assertEquals(42.0D, s.getMean());
    Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5));
    Assert.assertEquals(Double.NaN, s.getVariance());
    Assert.assertEquals(Double.NaN, s.getStandardDeviation());
    Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0]);
    Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1]);
    Assert.assertEquals(42.0D, s.getPercentile(0));
    Assert.assertEquals(42.0D, s.getPercentile(100));
  }
Esempio n. 17
0
 /** Test of getVariance method, of class Statistics. */
 @Test
 public strictfp void testGetVariance() {
   assertEquals(816.9807, instance.getVariance(), 0.0001);
 }
Esempio n. 18
0
 /** Test of getStandardDeviation method, of class Statistics. */
 @Test
 public strictfp void testGetStandardDeviation() {
   assertEquals(28.5828, instance.getStandardDeviation(), 0.0001);
 }