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
This commit is contained in:
parent
985378c6f2
commit
eb4d267f51
|
@ -57,7 +57,7 @@ import java.util.Arrays;
|
||||||
import org.apache.commons.math.stat.univariate.AbstractUnivariateStatistic;
|
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 {
|
public class Percentile extends AbstractUnivariateStatistic {
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ public class Percentile extends AbstractUnivariateStatistic {
|
||||||
if (pos < 1) {
|
if (pos < 1) {
|
||||||
return sorted[0];
|
return sorted[0];
|
||||||
}
|
}
|
||||||
if (pos > n) {
|
if (pos >= n) {
|
||||||
return sorted[length - 1];
|
return sorted[length - 1];
|
||||||
}
|
}
|
||||||
double lower = sorted[intPos - 1];
|
double lower = sorted[intPos - 1];
|
||||||
|
|
|
@ -61,7 +61,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatisticAbstractTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cases for the {@link UnivariateStatistic} class.
|
* 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{
|
public class PercentileTest extends UnivariateStatisticAbstractTest{
|
||||||
|
|
||||||
|
@ -99,4 +99,9 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
|
||||||
return 20.82;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue