commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject cvs commit: jakarta-commons/math/src/test/org/apache/commons/math/stat/inference ChiSquareTestTest.java
Date Sat, 04 Dec 2004 20:52:43 GMT
psteitz     2004/12/04 12:52:43

  Modified:    math/src/test/org/apache/commons/math/stat/inference
                        ChiSquareTestTest.java
  Log:
  Added test case using 2-way table containing zeros (illustrates PR #32531).
  Increased accuracy of target values in one test case.
  
  Revision  Changes    Path
  1.4       +12 -2     jakarta-commons/math/src/test/org/apache/commons/math/stat/inference/ChiSquareTestTest.java
  
  Index: ChiSquareTestTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/inference/ChiSquareTestTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ChiSquareTestTest.java	26 Jun 2004 22:09:07 -0000	1.3
  +++ ChiSquareTestTest.java	4 Dec 2004 20:52:43 -0000	1.4
  @@ -113,7 +113,7 @@
           // Target values computed using R version 1.8.1 
           
           long[][] counts = { {40, 22, 43}, {91, 21, 28}, {60, 10, 22}};
  -        assertEquals( "chi-square test statistic", 22.709, testStatistic.chiSquare(counts),
1E-3);
  +        assertEquals( "chi-square test statistic", 22.709027688, testStatistic.chiSquare(counts),
1E-9);
           assertEquals("chi-square p-value", 0.0001448, testStatistic.chiSquareTest(counts),
1E-7);
           assertTrue("chi-square test reject", testStatistic.chiSquareTest(counts, 0.0002));
           assertTrue("chi-square test accept", !testStatistic.chiSquareTest(counts, 0.0001));
   
  @@ -179,5 +179,15 @@
               new org.apache.commons.math.stat.inference.ChiSquareTestImpl(); 
           double cst = csti.chiSquareTest(exp, obs); 
           assertEquals("chi-square p-value", 0.0, cst, 1E-3);
  +    }
  +    
  +    /** Contingency table containing zeros - PR # 32531 */
  +    public void testChiSquareZeroCount() throws Exception {
  +        // Target values computed using R version 1.8.1 
  +        long[][] counts = { {40, 0, 4}, {91, 1, 2}, {60, 2, 0}};
  +        assertEquals( "chi-square test statistic", 9.67444662263,
  +                testStatistic.chiSquare(counts), 1E-9);
  +        assertEquals("chi-square p-value", 0.0462835770603,
  +                testStatistic.chiSquareTest(counts), 1E-9);       
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message