From eb4d267f51ff192b928be1d85ccb5f56015f19d3 Mon Sep 17 00:00:00 2001 From: "Mark R. Diggory" Date: Thu, 16 Oct 2003 15:15:04 +0000 Subject: [PATCH] PR: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23453 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 --- .../commons/math/stat/univariate/rank/Percentile.java | 4 ++-- .../commons/math/stat/univariate/rank/PercentileTest.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java b/src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java index 99dbd648b..e3d8da62a 100644 --- a/src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java +++ b/src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java @@ -57,7 +57,7 @@ import java.util.Arrays; import org.apache.commons.math.stat.univariate.AbstractUnivariateStatistic; /** - * @version $Revision: 1.6 $ $Date: 2003/10/13 08:10:58 $ + * @version $Revision: 1.7 $ $Date: 2003/10/16 15:15:04 $ */ public class Percentile extends AbstractUnivariateStatistic { @@ -145,7 +145,7 @@ public class Percentile extends AbstractUnivariateStatistic { if (pos < 1) { return sorted[0]; } - if (pos > n) { + if (pos >= n) { return sorted[length - 1]; } double lower = sorted[intPos - 1]; diff --git a/src/test/org/apache/commons/math/stat/univariate/rank/PercentileTest.java b/src/test/org/apache/commons/math/stat/univariate/rank/PercentileTest.java index 33fc406d9..20e9861fe 100644 --- a/src/test/org/apache/commons/math/stat/univariate/rank/PercentileTest.java +++ b/src/test/org/apache/commons/math/stat/univariate/rank/PercentileTest.java @@ -61,7 +61,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest; /** * Test cases for the {@link UnivariateStatistic} class. - * @version $Revision: 1.4 $ $Date: 2003/10/13 08:08:39 $ + * @version $Revision: 1.5 $ $Date: 2003/10/16 15:15:04 $ */ public class PercentileTest extends UnivariateStatisticAbstractTest{ @@ -99,4 +99,9 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{ return 20.82; } + public void testHighPercentile(){ + double[] d = new double[]{1, 2, 3}; + Percentile p = new Percentile(75); + assertEquals(3.0, p.evaluate(d), 1.0e-5); + } }