Esempio n. 1
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. 2
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. 3
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. 4
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. 5
0
 @BeforeClass
 public static void setUpClass() throws Exception {
   for (double value : VALUES) {
     instance.addValue(value);
   }
 }