commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r817128 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/random/EmpiricalDistribution.java site/xdoc/changes.xml test/java/org/apache/commons/math/random/EmpiricalDistributionTest.java
Date Mon, 21 Sep 2009 01:30:54 GMT
Author: psteitz
Date: Mon Sep 21 01:30:53 2009
New Revision: 817128

URL: http://svn.apache.org/viewvc?rev=817128&view=rev
Log:
Fixed implementation of EmpiricalDistributionImpl#getUpperBounds to match interface
contract.  Added getGeneratorUpperBounds method to EmpiricalDistributionImpl providing previous
behavior.

Jira: Math-298

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistribution.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/EmpiricalDistributionTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistribution.java?rev=817128&r1=817127&r2=817128&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistribution.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistribution.java
Mon Sep 21 01:30:53 2009
@@ -124,7 +124,7 @@
     /**
      * Returns the array of upper bounds for the bins.  Bins are: <br/>
      * [min,upperBounds[0]],(upperBounds[0],upperBounds[1]],...,
-     *  (upperBounds[binCount-1],max].
+     *  (upperBounds[binCount-2], upperBounds[binCount-1] = max].
      *
      * @return array of bin upper bounds
      */

Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=817128&r1=817127&r2=817128&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Mon Sep 21 01:30:53 2009
@@ -39,6 +39,11 @@
   </properties>
   <body>
     <release version="2.1" date="TBD" description="TBD">
+      <action dev="psteitz" tyoe="fix" issue="MATH-298">
+        Fixed implementation of EmpiricalDistributionImpl#getUpperBounds to match
+        interface contract.  Added getGeneratorUpperBounds method to
+        EmpiricalDistributionImpl providing previous behavior.
+      </action>
       <action dev="luc" type="fix" issue="MATH-293" due-to="Benjamin McCann">
         Fixed a OutOfBoundException in simplex solver when some constraints are tight.
       </action>

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/EmpiricalDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/EmpiricalDistributionTest.java?rev=817128&r1=817127&r2=817128&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/EmpiricalDistributionTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/EmpiricalDistributionTest.java
Mon Sep 21 01:30:53 2009
@@ -118,7 +118,7 @@
           (empiricalDistribution2.getSampleStats().getStandardDeviation(),
                 1.0173699343977738,10E-7);
 
-        double[] bounds = empiricalDistribution2.getUpperBounds();
+        double[] bounds = ((EmpiricalDistributionImpl) empiricalDistribution2).getGeneratorUpperBounds();
         assertEquals(bounds.length, 100);
         assertEquals(bounds[99], 1.0, 10e-12);
 
@@ -226,6 +226,20 @@
             fail("wrong exception caught");
         }
     }
+    
+    /**
+     * MATH-298
+     */
+    public void testGetBinUpperBounds() {
+        double[] testData = {0, 1, 1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10};
+        EmpiricalDistributionImpl dist = new EmpiricalDistributionImpl(5);
+        dist.load(testData);
+        double[] expectedBinUpperBounds = {2, 4, 6, 8, 10};
+        double[] expectedGeneratorUpperBounds = {4d/13d, 7d/13d, 9d/13d, 11d/13d, 1};
+        double tol = 10E-12;
+        TestUtils.assertEquals(expectedBinUpperBounds, dist.getUpperBounds(), tol);
+        TestUtils.assertEquals(expectedGeneratorUpperBounds, dist.getGeneratorUpperBounds(),
tol);  
+    }
 
     private void verifySame(EmpiricalDistribution d1, EmpiricalDistribution d2) {
         assertEquals(d1.isLoaded(), d2.isLoaded());



Mime
View raw message