You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2012/09/09 00:15:33 UTC

svn commit: r1382380 - in /commons/proper/math/trunk/src: changes/ main/java/org/apache/commons/math3/distribution/ test/java/org/apache/commons/math3/distribution/

Author: psteitz
Date: Sat Sep  8 22:15:32 2012
New Revision: 1382380

URL: http://svn.apache.org/viewvc?rev=1382380&view=rev
Log:
Clarified definition of isSupportXxxBoundInclusive in RealDistribution interface,
made code consistent with the definition, and deprecated these methods, marking
for removal in 4.0.
JIRA: MATH-859

Modified:
    commons/proper/math/trunk/src/changes/changes.xml
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/FDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/RealDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/UniformRealDistribution.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/distribution/RealDistributionAbstractTest.java

Modified: commons/proper/math/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/changes/changes.xml?rev=1382380&r1=1382379&r2=1382380&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Sat Sep  8 22:15:32 2012
@@ -52,6 +52,11 @@ If the output is not quite correct, chec
   <body>
     <release version="3.1" date="TBD" description="
 ">
+      <action dev="psteitz" type="update" issue="MATH-859">
+        Clarified definition of isSupportXxxBoundInclusive in RealDistribution
+        interface, made code consistent with the definition, and deprecated
+        these methods, marking for removal in 4.0.
+      </action>
       <action dev="erans" type="update" issue="MATH-841" due-to="Sebastien Riou">
         Performance improvement in computation of the greatest common divisor
         (in class "o.a.c.m.util.ArithmeticUtils").

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/FDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/FDistribution.java?rev=1382380&r1=1382379&r2=1382380&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/FDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/FDistribution.java Sat Sep  8 22:15:32 2012
@@ -272,7 +272,7 @@ public class FDistribution extends Abstr
 
     /** {@inheritDoc} */
     public boolean isSupportLowerBoundInclusive() {
-        return true;
+        return false;
     }
 
     /** {@inheritDoc} */

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/RealDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/RealDistribution.java?rev=1382380&r1=1382379&r2=1382380&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/RealDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/RealDistribution.java Sat Sep  8 22:15:32 2012
@@ -137,18 +137,26 @@ public interface RealDistribution {
     double getSupportUpperBound();
 
     /**
-     * Use this method to get information about whether the lower bound
-     * of the support is inclusive or not.
-     *
-     * @return whether the lower bound of the support is inclusive or not
+     * Whether or not the lower bound of support is in the domain of the density
+     * function.  Returns true iff {@code getSupporLowerBound()} is finite and
+     * {@code density(getSupportLowerBound())} returns a non-NaN, non-infinite
+     * value.
+     *
+     * @return true if the lower bound of support is finite and the density 
+     * function returns a non-NaN, non-infinite value there
+     * @deprecated to be removed in 4.0
      */
     boolean isSupportLowerBoundInclusive();
 
     /**
-     * Use this method to get information about whether the upper bound
-     * of the support is inclusive or not.
-     *
-     * @return whether the upper bound of the support is inclusive or not
+     * Whether or not the upper bound of support is in the domain of the density
+     * function.  Returns true iff {@code getSupportUpperBound()} is finite and
+     * {@code density(getSupportUpperBound())} returns a non-NaN, non-infinite
+     * value.
+     *
+     * @return true if the upper bound of support is finite and the density 
+     * function returns a non-NaN, non-infinite value there
+     * @deprecated to be removed in 4.0
      */
     boolean isSupportUpperBoundInclusive();
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/UniformRealDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/UniformRealDistribution.java?rev=1382380&r1=1382379&r2=1382380&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/UniformRealDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/UniformRealDistribution.java Sat Sep  8 22:15:32 2012
@@ -181,7 +181,7 @@ public class UniformRealDistribution ext
 
     /** {@inheritDoc} */
     public boolean isSupportUpperBoundInclusive() {
-        return false;
+        return true;
     }
 
     /**

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/distribution/RealDistributionAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/distribution/RealDistributionAbstractTest.java?rev=1382380&r1=1382379&r2=1382380&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/distribution/RealDistributionAbstractTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/distribution/RealDistributionAbstractTest.java Sat Sep  8 22:15:32 2012
@@ -338,6 +338,38 @@ public abstract class RealDistributionAb
                                     integrationTestPoints.get(i)), tol);
         }
     }
+    
+    /**
+     * Verify that isSupportLowerBoundInclusvie returns true iff the lower bound
+     * is finite and density is non-NaN, non-infinite there.
+     */
+    @Test
+    public void testIsSupportLowerBoundInclusive() {
+        final double lowerBound = distribution.getSupportLowerBound();
+        double result = Double.NaN;
+        result = distribution.density(lowerBound);
+        Assert.assertEquals(
+                !Double.isInfinite(lowerBound) && !Double.isNaN(result) &&
+                !Double.isInfinite(result),
+                distribution.isSupportLowerBoundInclusive());
+         
+    }
+    
+    /**
+     * Verify that isSupportUpperBoundInclusvie returns true iff the upper bound
+     * is finite and density is non-NaN, non-infinite there.
+     */
+    @Test
+    public void testIsSupportUpperBoundInclusive() {
+        final double upperBound = distribution.getSupportUpperBound();
+        double result = Double.NaN;
+        result = distribution.density(upperBound);
+        Assert.assertEquals(
+                !Double.isInfinite(upperBound) && !Double.isNaN(result) &&
+                !Double.isInfinite(result),
+                distribution.isSupportUpperBoundInclusive());
+         
+    }
 
     //------------------ Getters / Setters for test instance data -----------
     /**