You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2012/07/22 17:00:53 UTC
svn commit: r1364318 - in /commons/proper/math/trunk/src: changes/changes.xml
main/java/org/apache/commons/math3/stat/descriptive/rank/Percentile.java
Author: tn
Date: Sun Jul 22 15:00:52 2012
New Revision: 1364318
URL: http://svn.apache.org/viewvc?rev=1364318&view=rev
Log:
[MATH-578] Improve performance of quantile evaluation in Percentile for special cases.
Modified:
commons/proper/math/trunk/src/changes/changes.xml
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Percentile.java
Modified: commons/proper/math/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/changes/changes.xml?rev=1364318&r1=1364317&r2=1364318&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Sun Jul 22 15:00:52 2012
@@ -52,6 +52,10 @@ If the output is not quite correct, chec
<body>
<release version="3.1" date="TBD" description="
">
+ <action dev="tn" type="fix" issue="MATH-578">
+ Improve performance of quantile evaluation in Percentile class for cases
+ with lots of equal values.
+ </action>
<action dev="erans" type="add" issue="MATH-797">
New framework for Gauss integration schemes (in package
"o.a.c.m.analysis.integration.gauss").
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Percentile.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Percentile.java?rev=1364318&r1=1364317&r2=1364318&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Percentile.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Percentile.java Sun Jul 22 15:00:52 2012
@@ -333,11 +333,11 @@ public class Percentile extends Abstract
} else if (k < pivot) {
// the element is in the left partition
end = pivot;
- node = Math.min(2 * node + 1, pivotsHeap.length); // the min is here to avoid integer overflow
+ node = FastMath.min(2 * node + 1, pivotsHeap.length); // the min is here to avoid integer overflow
} else {
// the element is in the right partition
begin = pivot + 1;
- node = Math.min(2 * node + 2, pivotsHeap.length); // the min is here to avoid integer overflow
+ node = FastMath.min(2 * node + 2, pivotsHeap.length); // the min is here to avoid integer overflow
}
}
@@ -401,10 +401,10 @@ public class Percentile extends Abstract
int i = begin + 1;
int j = end - 1;
while (i < j) {
- while ((i < j) && (work[j] >= value)) {
+ while ((i < j) && (work[j] > value)) {
--j;
}
- while ((i < j) && (work[i] <= value)) {
+ while ((i < j) && (work[i] < value)) {
++i;
}