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

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1134802 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2011-06-11 22:28:52 +00:00
parent 58d1885283
commit e84687da98
3 changed files with 15 additions and 3 deletions

View File

@ -41,9 +41,10 @@ import org.apache.commons.math.util.MathUtils;
* <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>

View File

@ -52,6 +52,10 @@ The <action> type attribute can be add,update,fix,remove.
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>

View File

@ -52,6 +52,13 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
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() {