psteitz     2004/07/11 11:42:07

  Modified:    math/src/test/org/apache/commons/math/stat
                        StatUtilsTest.java
  Log:
  Added tests for methods computing variance from mean, removed obsolete tests.
  
  Revision  Changes    Path
  1.18      +6 -42     
jakarta-commons/math/src/test/org/apache/commons/math/stat/StatUtilsTest.java
  
  Index: StatUtilsTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/StatUtilsTest.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- StatUtilsTest.java        24 May 2004 05:33:42 -0000      1.17
  +++ StatUtilsTest.java        11 Jul 2004 18:42:07 -0000      1.18
  @@ -62,6 +62,7 @@
           assertEquals("sum", sum, StatUtils.sum(values), tolerance);
           assertEquals("sumsq", sumSq, StatUtils.sumSq(values), tolerance);
           assertEquals("var", var, StatUtils.variance(values), tolerance);
  +        assertEquals("var with mean", var, StatUtils.variance(values, mean), 
tolerance);
           assertEquals("mean", mean, StatUtils.mean(values), tolerance);
           assertEquals("min", min, StatUtils.min(values), tolerance);
           assertEquals("max", max, StatUtils.max(values), tolerance);
  @@ -87,47 +88,6 @@
               StatUtils.variance(values) == 0);
       }
   
  -    public void testSkewAndKurtosis() {
  -
  -        double[] values =
  -            {
  -                12.5,
  -                12,
  -                11.8,
  -                14.2,
  -                14.9,
  -                14.5,
  -                21,
  -                8.2,
  -                10.3,
  -                11.3,
  -                14.1,
  -                9.9,
  -                12.2,
  -                12,
  -                12.1,
  -                11,
  -                19.8,
  -                11,
  -                10,
  -                8.8,
  -                9,
  -                12.3 };
  -
  -        assertEquals("mean", 12.40455, StatUtils.mean(values), 0.0001);
  -        assertEquals("variance", 10.00236, StatUtils.variance(values), 0.0001);
  -    }
  -
  -    public void testProductAndGeometricMean() throws Exception {
  -        double[] values = { 1.0, 2.0, 3.0, 4.0 };
  -
  -        assertEquals(
  -            "Product not expected",
  -            24.0,
  -            StatUtils.product(values),
  -            Double.MIN_VALUE);
  -    }
  -
       public void testArrayIndexConditions() throws Exception {
           double[] values = { 1.0, 2.0, 3.0, 4.0 };
   
  @@ -309,6 +269,10 @@
           // test many
           x = new double[] {one, two, two, three};
           TestUtils.assertEquals(0.5, StatUtils.variance(x, 2, 2), tolerance);
  +        
  +        // test precomputed mean
  +        x = new double[] {one, two, two, three};
  +        TestUtils.assertEquals(0.5, StatUtils.variance(x,2.5, 2, 2), tolerance);
       }
       
       public void testMax() {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to