Skip to content

Commit eb4d267

Browse files
committed
Submitted by: Brent Warden Reviewed by: Mark Diggory git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141003 13f79535-47bb-0310-9956-ffa450edef68
1 parent 985378c commit eb4d267

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import org.apache.commons.math.stat.univariate.AbstractUnivariateStatistic;
5858

5959
/**
60-
* @version $Revision: 1.6 $ $Date: 2003/10/13 08:10:58 $
60+
* @version $Revision: 1.7 $ $Date: 2003/10/16 15:15:04 $
6161
*/
6262
public class Percentile extends AbstractUnivariateStatistic {
6363

@@ -145,7 +145,7 @@ public double evaluate(
145145
if (pos < 1) {
146146
return sorted[0];
147147
}
148-
if (pos > n) {
148+
if (pos >= n) {
149149
return sorted[length - 1];
150150
}
151151
double lower = sorted[intPos - 1];

src/test/org/apache/commons/math/stat/univariate/rank/PercentileTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
/**
6363
* Test cases for the {@link UnivariateStatistic} class.
64-
* @version $Revision: 1.4 $ $Date: 2003/10/13 08:08:39 $
64+
* @version $Revision: 1.5 $ $Date: 2003/10/16 15:15:04 $
6565
*/
6666
public class PercentileTest extends UnivariateStatisticAbstractTest{
6767

@@ -99,4 +99,9 @@ public double expectedValue() {
9999
return 20.82;
100100
}
101101

102+
public void testHighPercentile(){
103+
double[] d = new double[]{1, 2, 3};
104+
Percentile p = new Percentile(75);
105+
assertEquals(3.0, p.evaluate(d), 1.0e-5);
106+
}
102107
}

0 commit comments

Comments
 (0)