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 2011/06/12 00:28:53 UTC

svn commit: r1134802 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java site/xdoc/changes.xml test/java/org/apache/commons/math/stat/descriptive/rank/PercentileTest.java

Author: psteitz
Date: Sat Jun 11 22:28:52 2011
New Revision: 1134802

URL: http://svn.apache.org/viewvc?rev=1134802&view=rev
Log:
Fixed error in javadoc describing the behavior of the Percentile algorithm
for small percentiles in small datasets.
JIRA: MATH-582
Reported by Andre Herbst
Patched by Christopher Nix

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/rank/PercentileTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java?rev=1134802&r1=1134801&r2=1134802&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java Sat Jun 11 22:28:52 2011
@@ -41,9 +41,10 @@ import org.apache.commons.math.util.Math
  * <li>Compute the estimated percentile position
  * <code> pos = p * (n + 1) / 100</code> and the difference, <code>d</code>
  * between <code>pos</code> and <code>floor(pos)</code> (i.e. the fractional
- * part of <code>pos</code>).  If <code>pos >= n</code> return the largest
- * element in the array; otherwise</li>
- * <li>Let <code>lower</code> be the element in position
+ * part of <code>pos</code>).</li>
+ * <li> If <code>pos < 1</code> return the smallest element in the array.</li>
+ * <li> Else if <code>pos >= n</code> return the largest element in the array.</li>
+ * <li> Else let <code>lower</code> be the element in position
  * <code>floor(pos)</code> in the array and let <code>upper</code> be the
  * next element in the array.  Return <code>lower + d * (upper - lower)</code>
  * </li>

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=1134802&r1=1134801&r2=1134802&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Sat Jun 11 22:28:52 2011
@@ -52,6 +52,10 @@ The <action> type attribute can be add,u
     If the output is not quite correct, check for invisible trailing spaces!
      -->
     <release version="3.0" date="TBD" description="TBD">
+      <action dev="psteitz" type="fix" due-to="Christopher Nix">
+        Fixed error in javadoc describing the behavior of the Percentile algorithm for
+        small percentiles in small datasets.
+      </action>
       <action dev="erans" type="add" due-to="Thomas Neidhart">
         New "filter" package. Initial implementation of Kalman filter.
       </action>

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/rank/PercentileTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/rank/PercentileTest.java?rev=1134802&r1=1134801&r2=1134802&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/rank/PercentileTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/rank/PercentileTest.java Sat Jun 11 22:28:52 2011
@@ -52,6 +52,13 @@ public class PercentileTest extends Univ
         Percentile p = new Percentile(75);
         Assert.assertEquals(3.0, p.evaluate(d), 1.0e-5);
     }
+    
+    @Test
+    public void testLowPercentile() {
+        double[] d = new double[] {0, 1};
+        Percentile p = new Percentile(25);
+        Assert.assertEquals(0d, p.evaluate(d), Double.MIN_VALUE);
+    }
 
     @Test
     public void testPercentile() {