This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git

commit e6bc7a4d31eaea79eee58fa096866f5c95d78470
Author: Gilles Sadowski <gillese...@gmail.com>
AuthorDate: Sat Jul 17 14:18:38 2021 +0200

    Use functionality from "Commons RNG".
---
 .../math4/legacy/stat/ranking/NaturalRanking.java      | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git 
a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRanking.java
 
b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRanking.java
index 627dfaf..9aab512 100644
--- 
a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRanking.java
+++ 
b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRanking.java
@@ -22,11 +22,11 @@ import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.commons.math4.legacy.exception.MathInternalError;
-import org.apache.commons.math4.legacy.exception.NotANumberException;
 import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.random.RandomUtils;
+import org.apache.commons.rng.sampling.distribution.UniformLongSampler;
+import org.apache.commons.math4.legacy.exception.MathInternalError;
+import org.apache.commons.math4.legacy.exception.NotANumberException;
 import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
 
 
@@ -85,7 +85,7 @@ public class NaturalRanking implements RankingAlgorithm {
     private final TiesStrategy tiesStrategy;
 
     /** Source of random data - used only when ties strategy is RANDOM. */
-    private final RandomUtils.DataGenerator randomData;
+    private final UniformRandomProvider random;
 
     /**
      * Create a NaturalRanking with default strategies for handling ties and 
NaNs.
@@ -152,14 +152,14 @@ public class NaturalRanking implements RankingAlgorithm {
     /**
      * @param nanStrategy NaN strategy.
      * @param tiesStrategy Tie strategy.
-     * @param randomGenerator RNG.
+     * @param random RNG.
      */
     private NaturalRanking(NaNStrategy nanStrategy,
                            TiesStrategy tiesStrategy,
-                           UniformRandomProvider randomGenerator) {
+                           UniformRandomProvider random) {
         this.nanStrategy = nanStrategy;
         this.tiesStrategy = tiesStrategy;
-        randomData = RandomUtils.createDataGenerator(randomGenerator);
+        this.random = random;
     }
 
     /**
@@ -354,10 +354,10 @@ public class NaturalRanking implements RankingAlgorithm {
             case RANDOM:    // Fill with random integral values in [c, c + 
length - 1]
                 Iterator<Integer> iterator = tiesTrace.iterator();
                 long f = AccurateMath.round(c);
+                final UniformLongSampler sampler = 
UniformLongSampler.of(random, f, f + length - 1);
                 while (iterator.hasNext()) {
                     // No advertised exception because args are guaranteed 
valid
-                    ranks[iterator.next()] =
-                        randomData.nextLong(f, f + length - 1);
+                    ranks[iterator.next()] = sampler.sample();
                 }
                 break;
             case SEQUENTIAL:  // Fill sequentially from c to c + length - 1

Reply via email to