commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r699468 - in /commons/proper/math/branches/MATH_2_0/src: java/org/apache/commons/math/distribution/FDistributionImpl.java site/xdoc/changes.xml test/org/apache/commons/math/distribution/FDistributionTest.java
Date Fri, 26 Sep 2008 19:51:14 GMT
Author: luc
Date: Fri Sep 26 12:51:13 2008
New Revision: 699468

URL: http://svn.apache.org/viewvc?rev=699468&view=rev
Log:
propagated trunk changes from r699157 into branch 2.0
MATH-227.  fixed F distribution inverse CDF computation for small denominator degrees of freedom.

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/distribution/FDistributionImpl.java
    commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/distribution/FDistributionTest.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/distribution/FDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/distribution/FDistributionImpl.java?rev=699468&r1=699467&r2=699468&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/distribution/FDistributionImpl.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/distribution/FDistributionImpl.java
Fri Sep 26 12:51:13 2008
@@ -141,8 +141,13 @@
      * @return initial domain value
      */
     protected double getInitialDomain(double p) {
-        return getDenominatorDegreesOfFreedom() /
-            (getDenominatorDegreesOfFreedom() - 2.0);
+        double ret = 1.0;
+        double d = getDenominatorDegreesOfFreedom();
+        if (d > 2.0) {
+            // use mean
+            ret = d / (d - 2.0);
+        }
+        return ret;
     }
     
     /**

Modified: commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml?rev=699468&r1=699467&r2=699468&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml Fri Sep 26 12:51:13 2008
@@ -39,6 +39,9 @@
   </properties>
   <body>
     <release version="2.0" date="TBD" description="TBD">
+      <action dev="brentworden" type="fix" issue="MATH-227" due-to="Joerg Henning">
+        Fixed F distribution inverse CDF computation for small denominator degrees of freedom.
+      </action>
       <action dev="luc" type="fix" issue="MATH-226" due-to="Stuart Siegel">
         Fixed an error in CorrelatedRandomVectorGenerator leading to a component of
         the generated vector being constant.

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/distribution/FDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/distribution/FDistributionTest.java?rev=699468&r1=699467&r2=699468&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/distribution/FDistributionTest.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/distribution/FDistributionTest.java
Fri Sep 26 12:51:13 2008
@@ -105,4 +105,19 @@
         double x = fd.inverseCumulativeProbability(p);
         assertEquals(.999, x, 1.0e-5);
     }
+
+    public void testSmallDegreesOfFreedom() throws Exception {
+        org.apache.commons.math.distribution.FDistributionImpl fd =
+            new org.apache.commons.math.distribution.FDistributionImpl(
+                1.0, 1.0);
+        double p = fd.cumulativeProbability(0.975);
+        double x = fd.inverseCumulativeProbability(p);
+        assertEquals(0.975, x, 1.0e-5);
+
+        fd.setDenominatorDegreesOfFreedom(2.0);
+        p = fd.cumulativeProbability(0.975);
+        x = fd.inverseCumulativeProbability(p);
+        assertEquals(0.975, x, 1.0e-5);
+    }
+
 }



Mime
View raw message