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/regression SimpleRegressionTest.java
Date Fri, 10 Dec 2004 05:18:16 GMT
psteitz     2004/12/09 21:18:16

  Modified:    math/src/test/org/apache/commons/math/stat/inference
                        ChiSquareTestTest.java
               math/src/test/org/apache/commons/math/stat/regression
                        SimpleRegressionTest.java
  Log:
  Increased precision of target values used in tests.
  
  Revision  Changes    Path
  1.5       +9 -7      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ChiSquareTestTest.java	4 Dec 2004 20:52:43 -0000	1.4
  +++ ChiSquareTestTest.java	10 Dec 2004 05:18:16 -0000	1.5
  @@ -47,16 +47,16 @@
           // Target values computed using R version 1.8.1 
           // Some assembly required ;-)  
           //      Use sum((obs - exp)^2/exp) for the chi-square statistic and
  -        //      1 - pchisq(sum((obs - exp)^2/exp), obs.length - 1) for the p-value
  +        //      1 - pchisq(sum((obs - exp)^2/exp), length(obs) - 1) for the p-value
           
           long[] observed = {10, 9, 11};
           double[] expected = {10, 10, 10};
           assertEquals("chi-square statistic", 0.2,  testStatistic.chiSquare(expected, observed),
10E-12);
  -        assertEquals("chi-square p-value", 0.9048374, testStatistic.chiSquareTest(expected,
observed), 1E-7);
  +        assertEquals("chi-square p-value", 0.904837418036, testStatistic.chiSquareTest(expected,
observed), 1E-10);
           
           long[] observed1 = { 500, 623, 72, 70, 31 };
           double[] expected1 = { 485, 541, 82, 61, 37 };
  -        assertEquals( "chi-square test statistic", 16.41311, testStatistic.chiSquare(expected1,
observed1), 1E-5);
  +        assertEquals( "chi-square test statistic", 16.4131070362, testStatistic.chiSquare(expected1,
observed1), 1E-10);
           assertEquals("chi-square p-value", 0.002512096, testStatistic.chiSquareTest(expected1,
observed1), 1E-9);
           assertTrue("chi-square test reject", testStatistic.chiSquareTest(expected1, observed1,
0.003));
           assertTrue("chi-square test accept", !testStatistic.chiSquareTest(expected1, observed1,
0.002));
  @@ -114,13 +114,13 @@
           
           long[][] counts = { {40, 22, 43}, {91, 21, 28}, {60, 10, 22}};
           assertEquals( "chi-square test statistic", 22.709027688, testStatistic.chiSquare(counts),
1E-9);
  -        assertEquals("chi-square p-value", 0.0001448, testStatistic.chiSquareTest(counts),
1E-7);
  +        assertEquals("chi-square p-value", 0.000144751460134, testStatistic.chiSquareTest(counts),
1E-9);
           assertTrue("chi-square test reject", testStatistic.chiSquareTest(counts, 0.0002));
           assertTrue("chi-square test accept", !testStatistic.chiSquareTest(counts, 0.0001));
   
           
           long[][] counts2 = {{10, 15}, {30, 40}, {60, 90} };
  -        assertEquals( "chi-square test statistic", 0.169, testStatistic.chiSquare(counts2),
1E-3);
  -        assertEquals("chi-square p-value", 0.919, testStatistic.chiSquareTest(counts2),
1E-3);
  +        assertEquals( "chi-square test statistic", 0.168965517241, testStatistic.chiSquare(counts2),
1E-9);
  +        assertEquals("chi-square p-value",0.918987499852, testStatistic.chiSquareTest(counts2),
1E-9);
           assertTrue("chi-square test accept", !testStatistic.chiSquareTest(counts2, 0.1));

           
           // ragged input array
  @@ -179,6 +179,8 @@
               new org.apache.commons.math.stat.inference.ChiSquareTestImpl(); 
           double cst = csti.chiSquareTest(exp, obs); 
           assertEquals("chi-square p-value", 0.0, cst, 1E-3);
  +        assertEquals( "chi-square test statistic", 
  +                3624883.342907764, testStatistic.chiSquare(exp, obs), 1E-9);
       }
       
       /** Contingency table containing zeros - PR # 32531 */
  
  
  
  1.4       +4 -4      jakarta-commons/math/src/test/org/apache/commons/math/stat/regression/SimpleRegressionTest.java
  
  Index: SimpleRegressionTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/regression/SimpleRegressionTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SimpleRegressionTest.java	24 Oct 2004 21:47:16 -0000	1.3
  +++ SimpleRegressionTest.java	10 Dec 2004 05:18:16 -0000	1.4
  @@ -117,7 +117,7 @@
           regression.addData(corrData);
           assertEquals("number of observations", 17, regression.getN());
           assertEquals("r-square", .896123, regression.getRSquare(), 10E-6);
  -        assertEquals("r", -.946638, regression.getR(), 10E-6);
  +        assertEquals("r", -0.94663767742, regression.getR(), 1E-10);
       }
   
       public void testNaNs() {
  @@ -210,8 +210,8 @@
                   regression.getSlopeStdErr(), 1E-8);
           assertEquals("std err intercept",4.17718672,
                   regression.getInterceptStdErr(),1E-8);
  -        assertEquals("significance", 0.26183,
  -                regression.getSignificance(),1E-5);    
  +        assertEquals("significance", 0.261829133982,
  +                regression.getSignificance(),1E-11);    
           assertEquals("slope conf interval half-width", 2.97802204827, 
                   regression.getSlopeConfidenceInterval(),1E-8);
           //------------- End R-verified tests -------------------------------
  
  
  

---------------------------------------------------------------------
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