Skip to content

Commit e195ee2

Browse files
committed
MATH-1672: Remove stat.ranking package
Functionality has been transferred to the Commons Statistics ranking module.
1 parent 95847b7 commit e195ee2

File tree

15 files changed

+27
-983
lines changed

15 files changed

+27
-983
lines changed

commons-math-legacy/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
<artifactId>commons-statistics-distribution</artifactId>
5252
</dependency>
5353

54+
<dependency>
55+
<groupId>org.apache.commons</groupId>
56+
<artifactId>commons-statistics-ranking</artifactId>
57+
</dependency>
58+
5459
<dependency>
5560
<groupId>org.apache.commons</groupId>
5661
<artifactId>commons-numbers-core</artifactId>

commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/correlation/SpearmansCorrelation.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
2323
import org.apache.commons.math4.legacy.linear.BlockRealMatrix;
2424
import org.apache.commons.math4.legacy.linear.RealMatrix;
25-
import org.apache.commons.math4.legacy.stat.ranking.NaNStrategy;
26-
import org.apache.commons.math4.legacy.stat.ranking.NaturalRanking;
27-
import org.apache.commons.math4.legacy.stat.ranking.RankingAlgorithm;
25+
import org.apache.commons.statistics.ranking.NaNStrategy;
26+
import org.apache.commons.statistics.ranking.NaturalRanking;
27+
import org.apache.commons.statistics.ranking.RankingAlgorithm;
2828

2929
/**
3030
* Spearman's rank correlation. This implementation performs a rank
@@ -179,8 +179,8 @@ public double correlation(final double[] xArray, final double[] yArray) {
179179
throw new MathIllegalArgumentException(LocalizedFormats.INSUFFICIENT_DIMENSION,
180180
xArray.length, 2);
181181
} else {
182-
return new PearsonsCorrelation().correlation(rankingAlgorithm.rank(xArray),
183-
rankingAlgorithm.rank(yArray));
182+
return new PearsonsCorrelation().correlation(rankingAlgorithm.apply(xArray),
183+
rankingAlgorithm.apply(yArray));
184184
}
185185
}
186186

@@ -194,7 +194,7 @@ public double correlation(final double[] xArray, final double[] yArray) {
194194
private RealMatrix rankTransform(final RealMatrix matrix) {
195195
RealMatrix transformed = matrix.copy();
196196
for (int i = 0; i < transformed.getColumnDimension(); i++) {
197-
transformed.setColumn(i, rankingAlgorithm.rank(transformed.getColumn(i)));
197+
transformed.setColumn(i, rankingAlgorithm.apply(transformed.getColumn(i)));
198198
}
199199

200200
return transformed;

commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Median.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
2020
import org.apache.commons.math4.legacy.exception.NullArgumentException;
21-
import org.apache.commons.math4.legacy.stat.ranking.NaNStrategy;
21+
import org.apache.commons.statistics.ranking.NaNStrategy;
2222

2323

2424
/**

commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Percentile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
2929
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
3030
import org.apache.commons.math4.legacy.stat.descriptive.AbstractUnivariateStatistic;
31-
import org.apache.commons.math4.legacy.stat.ranking.NaNStrategy;
3231
import org.apache.commons.math4.core.jdkmath.JdkMath;
3332
import org.apache.commons.math4.legacy.core.MathArrays;
33+
import org.apache.commons.statistics.ranking.NaNStrategy;
3434

3535
/**
3636
* Provides percentile computation.

commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/ranking/NaNStrategy.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)