You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2016/12/14 16:40:25 UTC

[1/6] [math] MATH-1393: Remove code provided in "Commons RNG".

Repository: commons-math
Updated Branches:
  refs/heads/master 5c753a87c -> 657b1b49d


MATH-1393: Remove code provided in "Commons RNG".


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/d198cc8c
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/d198cc8c
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/d198cc8c

Branch: refs/heads/master
Commit: d198cc8cae8e42aed25b7ea8af6f1b7960e8a6bb
Parents: 5c753a8
Author: Gilles <er...@apache.org>
Authored: Wed Dec 14 15:52:02 2016 +0100
Committer: Gilles <er...@apache.org>
Committed: Wed Dec 14 17:38:28 2016 +0100

----------------------------------------------------------------------
 .../commons/math4/random/RandomUtils.java       |  86 -----------
 .../RandomUtilsDataGeneratorAbstractTest.java   | 142 -------------------
 2 files changed, 228 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/d198cc8c/src/main/java/org/apache/commons/math4/random/RandomUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/RandomUtils.java b/src/main/java/org/apache/commons/math4/random/RandomUtils.java
index 8f9c804..7b2cb9e 100644
--- a/src/main/java/org/apache/commons/math4/random/RandomUtils.java
+++ b/src/main/java/org/apache/commons/math4/random/RandomUtils.java
@@ -30,7 +30,6 @@ import org.apache.commons.math4.exception.NotStrictlyPositiveException;
 import org.apache.commons.math4.exception.NumberIsTooLargeException;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.math4.util.MathArrays;
 
 /**
  * Factory for creating generators of miscellaneous data.
@@ -403,90 +402,5 @@ public class RandomUtils {
 
             return u * upper + (1.0 - u) * lower;
         }
-
-        /**
-         * Generates an integer array of length {@code k} whose entries are selected
-         * randomly, without repetition, from the integers {@code 0, ..., n - 1}
-         * (inclusive).
-         * <p>
-         * Generated arrays represent permutations of {@code n} taken {@code k} at a
-         * time.
-         * </p>
-         * <p>
-         * This method calls {@link MathArrays#shuffle(int[],UniformRandomProvider)
-         * MathArrays.shuffle} in order to create a random shuffle of the set
-         * of natural numbers {@code { 0, 1, ..., n - 1 }}.
-         * </p>
-         *
-         * @param n Domain of the permutation.
-         * @param k Size of the permutation.
-         * @return a random {@code k}-permutation of {@code n}, as an array of
-         * integers.
-         * @throws NumberIsTooLargeException if {@code k > n}.
-         * @throws NotStrictlyPositiveException if {@code k <= 0}.
-         */
-        public int[] nextPermutation(int n,
-                                     int k)
-            throws NumberIsTooLargeException, NotStrictlyPositiveException {
-            if (k > n) {
-                throw new NumberIsTooLargeException(LocalizedFormats.PERMUTATION_EXCEEDS_N,
-                                                    k, n, true);
-            }
-            if (k <= 0) {
-                throw new NotStrictlyPositiveException(LocalizedFormats.PERMUTATION_SIZE,
-                                                       k);
-            }
-
-            final int[] index = MathArrays.natural(n);
-            MathArrays.shuffle(index, rng);
-
-            // Return a new array containing the first "k" entries of "index".
-            return MathArrays.copyOf(index, k);
-        }
-
-        /**
-         * Returns a list of {@code k} objects selected randomly from the
-         * given {@code collection}.
-         *
-         * <p>
-         * Sampling is without replacement; but if {@code collection} contains
-         * identical objects, the sample may include repeats.  If all elements
-         * are distinct, the resulting object array represents a
-         * <a href="http://rkb.home.cern.ch/rkb/AN16pp/node250.html#SECTION0002500000000000000000">
-         * Simple Random Sample</a> of size {@code k} from the elements of
-         * the {@code collection}.
-         * </p>
-         * <p>
-         * This method calls {@link #nextPermutation(int,int) nextPermutation(c.size(), k)}
-         * in order to sample the collection.
-         * </p>
-         *
-         * @param <T> Type of objects held in the {@code collection}.
-         * @param collection Collection to be sampled.
-         * @param k Size of the sample.
-         * @return a random sample of {@code k} elements from the {@code collection}.
-         * @throws NumberIsTooLargeException if {@code k > collection.size()}.
-         * @throws NotStrictlyPositiveException if {@code k <= 0}.
-         */
-        public <T> List<T> nextSample(Collection<T> collection,
-                                      int k) {
-            final int len = collection.size();
-            if (k > len) {
-                throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_EXCEEDS_COLLECTION_SIZE,
-                                                    k, len, true);
-            }
-            if (k <= 0) {
-                throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, k);
-            }
-
-            final ArrayList<T> objects = new ArrayList<>(collection);
-            final int[] index = nextPermutation(len, k);
-            final List<T> result = new ArrayList<>(k);
-            for (int i = 0; i < k; i++) {
-                result.add(objects.get(index[i]));
-            }
-
-            return result;
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/d198cc8c/src/test/java/org/apache/commons/math4/random/RandomUtilsDataGeneratorAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/RandomUtilsDataGeneratorAbstractTest.java b/src/test/java/org/apache/commons/math4/random/RandomUtilsDataGeneratorAbstractTest.java
index 59170d4..dedf278 100644
--- a/src/test/java/org/apache/commons/math4/random/RandomUtilsDataGeneratorAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/random/RandomUtilsDataGeneratorAbstractTest.java
@@ -311,146 +311,4 @@ public abstract class RandomUtilsDataGeneratorAbstractTest {
             Assert.assertTrue(u > 0.99 && u < 1);
         }
     }
-
-    /** Tests for "nextSample" (sampling from Collection). */
-    @Test
-    public void testNextSample() {
-        Object[][] c = { { "0", "1" }, { "0", "2" }, { "0", "3" },
-                { "0", "4" }, { "1", "2" }, { "1", "3" }, { "1", "4" },
-                { "2", "3" }, { "2", "4" }, { "3", "4" } };
-        long[] observed = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-        double[] expected = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 };
-
-        HashSet<Object> cPop = new HashSet<>(); // {0,1,2,3,4}
-        for (int i = 0; i < 5; i++) {
-            cPop.add(Integer.toString(i));
-        }
-
-        Object[] sets = new Object[10]; // 2-sets from 5
-        for (int i = 0; i < 10; i++) {
-            HashSet<Object> hs = new HashSet<>();
-            hs.add(c[i][0]);
-            hs.add(c[i][1]);
-            sets[i] = hs;
-        }
-
-        for (int i = 0; i < 1000; i++) {
-            List<Object> cSamp = randomData.nextSample(cPop, 2);
-            observed[findSample(sets, cSamp)]++;
-        }
-
-        // Use ChiSquare dist with df = 10-1 = 9, alpha = 0.001
-        // Change to 21.67 for alpha = 0.01
-        Assert.assertTrue("chi-square test -- will fail about 1 in 1000 times",
-                          testStatistic.chiSquare(expected, observed) < 27.88);
-
-        // Make sure sample of size = size of collection returns same collection
-        HashSet<Object> hs = new HashSet<>();
-        hs.add("one");
-        List<Object> one = randomData.nextSample(hs, 1);
-        String oneString = (String) one.get(0);
-        if (one.size() != 1 ||
-            !oneString.equals("one")) {
-            Assert.fail("bad sample for set size = 1, sample size = 1");
-        }
-
-        // Make sure we fail for sample size > collection size.
-        try {
-            one = randomData.nextSample(hs, 2);
-            Assert.fail("sample size > set size, expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-
-        // Make sure we fail for empty collection.
-        try {
-            hs = new HashSet<>();
-            one = randomData.nextSample(hs, 0);
-            Assert.fail("n = k = 0, expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private int findSample(Object[] u, List<Object> sampList) {
-        Object[] samp = sampList.toArray(new Object[sampList.size()]);
-        for (int i = 0; i < u.length; i++) {
-            HashSet<Object> set = (HashSet<Object>) u[i];
-            HashSet<Object> sampSet = new HashSet<>();
-            for (int j = 0; j < samp.length; j++) {
-                sampSet.add(samp[j]);
-            }
-            if (set.equals(sampSet)) {
-                return i;
-            }
-        }
-        Assert.fail("sample not found:{" + samp[0] + "," + samp[1] + "}");
-        return -1;
-    }
-
-    /** tests for nextPermutation */
-    @Test
-    public void testNextPermutation() {
-        int[][] p = { { 0, 1, 2 }, { 0, 2, 1 }, { 1, 0, 2 }, { 1, 2, 0 },
-                      { 2, 0, 1 }, { 2, 1, 0 } };
-        long[] observed = { 0, 0, 0, 0, 0, 0 };
-        double[] expected = { 100, 100, 100, 100, 100, 100 };
-
-        for (int i = 0; i < 600; i++) {
-            int[] perm = randomData.nextPermutation(3, 3);
-            observed[findPerm(p, perm)]++;
-        }
-
-        String[] labels = {"{0, 1, 2}", "{ 0, 2, 1 }", "{ 1, 0, 2 }",
-                           "{ 1, 2, 0 }", "{ 2, 0, 1 }", "{ 2, 1, 0 }"};
-        TestUtils.assertChiSquareAccept(labels, expected, observed, 0.001);
-
-        // Check size = 1 boundary case
-        int[] perm = randomData.nextPermutation(1, 1);
-        if ((perm.length != 1) || (perm[0] != 0)) {
-            Assert.fail("bad permutation for n = 1, sample k = 1");
-
-            // Make sure we fail for k size > n
-            try {
-                perm = randomData.nextPermutation(2, 3);
-                Assert.fail("permutation k > n, expecting MathIllegalArgumentException");
-            } catch (MathIllegalArgumentException ex) {
-                // ignored
-            }
-
-            // Make sure we fail for n = 0
-            try {
-                perm = randomData.nextPermutation(0, 0);
-                Assert.fail("permutation k = n = 0, expecting MathIllegalArgumentException");
-            } catch (MathIllegalArgumentException ex) {
-                // ignored
-            }
-
-            // Make sure we fail for k < n < 0
-            try {
-                perm = randomData.nextPermutation(-1, -3);
-                Assert.fail("permutation k < n < 0, expecting MathIllegalArgumentException");
-            } catch (MathIllegalArgumentException ex) {
-                // ignored
-            }
-
-        }
-    }
-
-    private int findPerm(int[][] p, int[] samp) {
-        for (int i = 0; i < p.length; i++) {
-            boolean good = true;
-            for (int j = 0; j < samp.length; j++) {
-                if (samp[j] != p[i][j]) {
-                    good = false;
-                }
-            }
-            if (good) {
-                return i;
-            }
-        }
-        Assert.fail("permutation not found");
-        return -1;
-    }
 }


[4/6] [math] Typos.

Posted by er...@apache.org.
Typos.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/0956e2d2
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/0956e2d2
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/0956e2d2

Branch: refs/heads/master
Commit: 0956e2d2338531a96f2ff7d4ab405acc1b18421e
Parents: d198cc8
Author: Gilles <er...@apache.org>
Authored: Wed Dec 14 16:02:53 2016 +0100
Committer: Gilles <er...@apache.org>
Committed: Wed Dec 14 17:38:42 2016 +0100

----------------------------------------------------------------------
 .../RandomUtilsDataGeneratorAbstractTest.java     | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/0956e2d2/src/test/java/org/apache/commons/math4/random/RandomUtilsDataGeneratorAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/RandomUtilsDataGeneratorAbstractTest.java b/src/test/java/org/apache/commons/math4/random/RandomUtilsDataGeneratorAbstractTest.java
index dedf278..4c8b30f 100644
--- a/src/test/java/org/apache/commons/math4/random/RandomUtilsDataGeneratorAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/random/RandomUtilsDataGeneratorAbstractTest.java
@@ -242,34 +242,34 @@ public abstract class RandomUtilsDataGeneratorAbstractTest {
     }
 
     @Test
-    public void testNextUniformUniformPositiveBounds() {
+    public void testNextUniformPositiveBounds() {
         for (int i = 0; i < 5; i++) {
-            checkNextUniformUniform(0, 10);
+            checkNextUniform(0, 10);
         }
     }
 
     @Test
-    public void testNextUniformUniformNegativeToPositiveBounds() {
+    public void testNextUniformNegativeToPositiveBounds() {
         for (int i = 0; i < 5; i++) {
-            checkNextUniformUniform(-3, 5);
+            checkNextUniform(-3, 5);
         }
     }
 
     @Test
-    public void testNextUniformUniformNegaiveBounds() {
+    public void testNextUniformNegativeBounds() {
         for (int i = 0; i < 5; i++) {
-            checkNextUniformUniform(-7, -3);
+            checkNextUniform(-7, -3);
         }
     }
 
     @Test
-    public void testNextUniformUniformMaximalInterval() {
+    public void testNextUniformMaximalInterval() {
         for (int i = 0; i < 5; i++) {
-            checkNextUniformUniform(-Double.MAX_VALUE, Double.MAX_VALUE);
+            checkNextUniform(-Double.MAX_VALUE, Double.MAX_VALUE);
         }
     }
 
-    private void checkNextUniformUniform(double min, double max) {
+    private void checkNextUniform(double min, double max) {
         // Set up bin bounds - min, binBound[0], ..., binBound[binCount-2], max
         final int binCount = 5;
         final double binSize = max / binCount - min/binCount; // Prevent overflow in extreme value case


[3/6] [math] Unused import.

Posted by er...@apache.org.
Unused import.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/b0904d39
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/b0904d39
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/b0904d39

Branch: refs/heads/master
Commit: b0904d39a2298d386afc6e7089e78d0b2fbb79cf
Parents: c9709dd
Author: Gilles <er...@apache.org>
Authored: Wed Dec 14 16:54:15 2016 +0100
Committer: Gilles <er...@apache.org>
Committed: Wed Dec 14 17:38:42 2016 +0100

----------------------------------------------------------------------
 .../apache/commons/math4/userguide/ClusterAlgorithmComparison.java  | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/b0904d39/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java b/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
index f4d7de1..035c2e9 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
@@ -28,7 +28,6 @@ import java.awt.Shape;
 import java.awt.geom.Ellipse2D;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 
 import javax.swing.JComponent;


[2/6] [math] MATH-1393: Remove functionality provided by "Commons RNG".

Posted by er...@apache.org.
MATH-1393: Remove functionality provided by "Commons RNG".


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/657b1b49
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/657b1b49
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/657b1b49

Branch: refs/heads/master
Commit: 657b1b49da5ea1593dd7f950eae99a88a8ada87a
Parents: d2e40b6
Author: Gilles <er...@apache.org>
Authored: Wed Dec 14 17:27:11 2016 +0100
Committer: Gilles <er...@apache.org>
Committed: Wed Dec 14 17:38:42 2016 +0100

----------------------------------------------------------------------
 .../apache/commons/math4/util/MathArrays.java   | 106 -------------------
 .../org/apache/commons/math4/PerfTestUtils.java |   6 +-
 .../commons/math4/util/ArithmeticUtilsTest.java |   6 +-
 .../commons/math4/util/MathArraysTest.java      |  65 ------------
 .../commons/math4/util/MathUtilsTest.java       |   5 +-
 5 files changed, 11 insertions(+), 177 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/657b1b49/src/main/java/org/apache/commons/math4/util/MathArrays.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/util/MathArrays.java b/src/main/java/org/apache/commons/math4/util/MathArrays.java
index b56196f..cb9e360 100644
--- a/src/main/java/org/apache/commons/math4/util/MathArrays.java
+++ b/src/main/java/org/apache/commons/math4/util/MathArrays.java
@@ -1562,112 +1562,6 @@ public class MathArrays {
     }
 
     /**
-     * Specification for indicating that some operation applies
-     * before or after a given index.
-     */
-    public enum Position {
-        /** Designates the beginning of the array (near index 0). */
-        HEAD,
-        /** Designates the end of the array. */
-        TAIL
-    }
-
-    /**
-     * Shuffle the entries of the given array.
-     * The {@code start} and {@code pos} parameters select which portion
-     * of the array is randomized and which is left untouched.
-     *
-     * @see #shuffle(int[],int,Position,UniformRandomProvider)
-     *
-     * @param list Array whose entries will be shuffled (in-place).
-     * @param start Index at which shuffling begins.
-     * @param pos Shuffling is performed for index positions between
-     * {@code start} and either the end (if {@link Position#TAIL})
-     * or the beginning (if {@link Position#HEAD}) of the array.
-     */
-    public static void shuffle(int[] list,
-                               int start,
-                               Position pos) {
-        shuffle(list, start, pos, RandomSource.create(RandomSource.WELL_19937_C));
-    }
-
-    /**
-     * Shuffle the entries of the given array, using the
-     * <a href="http://en.wikipedia.org/wiki/Fisher\u2013Yates_shuffle#The_modern_algorithm">
-     * Fisher\u2013Yates</a> algorithm.
-     * The {@code start} and {@code pos} parameters select which portion
-     * of the array is randomized and which is left untouched.
-     *
-     * @param list Array whose entries will be shuffled (in-place).
-     * @param start Index at which shuffling begins.
-     * @param pos Shuffling is performed for index positions between
-     * {@code start} and either the end (if {@link Position#TAIL})
-     * or the beginning (if {@link Position#HEAD}) of the array.
-     * @param rng Random number generator.
-     */
-    public static void shuffle(int[] list,
-                               int start,
-                               Position pos,
-                               UniformRandomProvider rng) {
-        switch (pos) {
-        case TAIL: {
-            for (int i = list.length - 1; i >= start; i--) {
-                final int target;
-                if (i == start) {
-                    target = start;
-                } else {
-                    target = rng.nextInt(i - start + 1) + start;
-                }
-                final int temp = list[target];
-                list[target] = list[i];
-                list[i] = temp;
-            }
-        }
-            break;
-        case HEAD: {
-            for (int i = 0; i <= start; i++) {
-                final int target;
-                if (i == start) {
-                    target = start;
-                } else {
-                    target = rng.nextInt(start - i + 1) + i;
-                }
-                final int temp = list[target];
-                list[target] = list[i];
-                list[i] = temp;
-            }
-        }
-            break;
-        default:
-            throw new MathInternalError(); // Should never happen.
-        }
-    }
-
-    /**
-     * Shuffle the entries of the given array.
-     *
-     * @see #shuffle(int[],int,Position,UniformRandomProvider)
-     *
-     * @param list Array whose entries will be shuffled (in-place).
-     * @param rng Random number generator.
-     */
-    public static void shuffle(int[] list,
-                               UniformRandomProvider rng) {
-        shuffle(list, 0, Position.TAIL, rng);
-    }
-
-    /**
-     * Shuffle the entries of the given array.
-     *
-     * @see #shuffle(int[],int,Position,UniformRandomProvider)
-     *
-     * @param list Array whose entries will be shuffled (in-place).
-     */
-    public static void shuffle(int[] list) {
-        shuffle(list, RandomSource.create(RandomSource.WELL_19937_C));
-    }
-
-    /**
      * Returns an array representing the natural number {@code n}.
      *
      * @param n Natural number.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/657b1b49/src/test/java/org/apache/commons/math4/PerfTestUtils.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/PerfTestUtils.java b/src/test/java/org/apache/commons/math4/PerfTestUtils.java
index eb965ba..f1170a4 100644
--- a/src/test/java/org/apache/commons/math4/PerfTestUtils.java
+++ b/src/test/java/org/apache/commons/math4/PerfTestUtils.java
@@ -21,9 +21,9 @@ import java.util.regex.Matcher;
 import java.util.regex.MatchResult;
 import java.util.concurrent.Callable;
 
-import org.apache.commons.math4.util.MathArrays;
 import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.simple.RandomSource;
+import org.apache.commons.rng.sampling.PermutationSampler;
 import org.apache.commons.math4.exception.MathIllegalStateException;
 import org.apache.commons.math4.exception.NumberIsTooLargeException;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
@@ -124,11 +124,11 @@ public class PerfTestUtils {
 
         // Indices into the array containing the methods to benchmark.
         // The purpose is that at each repeat, the "methods" are called in a different order.
-        final int[] methodSequence = MathArrays.natural(numMethods);
+        final int[] methodSequence = PermutationSampler.natural(numMethods);
 
         try {
             for (int k = 0; k < repeatStat; k++) {
-                MathArrays.shuffle(methodSequence, rng);
+                PermutationSampler.shuffle(rng, methodSequence);
                 for (int n = 0; n < numMethods; n++) {
                     final int j = methodSequence[n]; // Index of the timed method.
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/657b1b49/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java b/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java
index 2de8ee1..f90b234 100644
--- a/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java
+++ b/src/test/java/org/apache/commons/math4/util/ArithmeticUtilsTest.java
@@ -20,6 +20,9 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.math.BigInteger;
 
+import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.simple.RandomSource;
+import org.apache.commons.rng.sampling.PermutationSampler;
 import org.apache.commons.math4.exception.MathArithmeticException;
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.junit.Assert;
@@ -124,8 +127,9 @@ public class ArithmeticUtilsTest {
     public void testGcdConsistency() {
         int[] primeList = {19, 23, 53, 67, 73, 79, 101, 103, 111, 131};
 
+        final UniformRandomProvider rng = RandomSource.create(RandomSource.WELL_19937_A);
         for (int i = 0; i < 20; i++) {
-            MathArrays.shuffle(primeList);
+            PermutationSampler.shuffle(rng, primeList);
             int p1 = primeList[0];
             int p2 = primeList[1];
             int p3 = primeList[2];

http://git-wip-us.apache.org/repos/asf/commons-math/blob/657b1b49/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/util/MathArraysTest.java b/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
index 8d491b2..0f0f06c 100644
--- a/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
+++ b/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
@@ -1109,71 +1109,6 @@ public class MathArraysTest {
     }
 
     @Test
-    public void testShuffleNoDuplicates() {
-        final int n = 100;
-        final int[] orig = MathArrays.natural(n);
-        MathArrays.shuffle(orig);
-
-        // Test that all (unique) entries exist in the shuffled array.
-        final int[] count = new int[n];
-        for (int i = 0; i < n; i++) {
-            count[orig[i]] += 1;
-        }
-
-        for (int i = 0; i < n; i++) {
-            Assert.assertEquals(1, count[i]);
-        }
-    }
-
-    @Test
-    public void testShuffleTail() {
-        final int[] orig = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-        final int[] list = orig.clone();
-        final int start = 4;
-        MathArrays.shuffle(list, start, MathArrays.Position.TAIL,
-                           RandomSource.create(RandomSource.WELL_19937_C, 7654321L));
-
-        // Ensure that all entries below index "start" did not move.
-        for (int i = 0; i < start; i++) {
-            Assert.assertEquals(orig[i], list[i]);
-        }
-
-        // Ensure that at least one entry has moved.
-        boolean ok = false;
-        for (int i = start; i < orig.length - 1; i++) {
-            if (orig[i] != list[i]) {
-                ok = true;
-                break;
-            }
-        }
-        Assert.assertTrue(ok);
-    }
-
-    @Test
-    public void testShuffleHead() {
-        final int[] orig = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-        final int[] list = orig.clone();
-        final int start = 4;
-        MathArrays.shuffle(list, start, MathArrays.Position.HEAD,
-                           RandomSource.create(RandomSource.WELL_19937_C, 1234567L));
-
-        // Ensure that all entries above index "start" did not move.
-        for (int i = start + 1; i < orig.length; i++) {
-            Assert.assertEquals(orig[i], list[i]);
-        }
-
-        // Ensure that at least one entry has moved.
-        boolean ok = false;
-        for (int i = 0; i <= start; i++) {
-            if (orig[i] != list[i]) {
-                ok = true;
-                break;
-            }
-        }
-        Assert.assertTrue(ok);
-    }
-
-    @Test
     public void testNatural() {
         final int n = 4;
         final int[] expected = {0, 1, 2, 3};

http://git-wip-us.apache.org/repos/asf/commons-math/blob/657b1b49/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java b/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java
index 17fe761..2e116a2 100644
--- a/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java
+++ b/src/test/java/org/apache/commons/math4/util/MathUtilsTest.java
@@ -21,6 +21,7 @@ import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.simple.RandomSource;
+import org.apache.commons.rng.sampling.PermutationSampler;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -109,8 +110,8 @@ public final class MathUtilsTest {
         // Generate a random permutation, making sure it is not the identity
         boolean isIdentity = true;
         do {
-            int[] permutation = MathArrays.natural(10);
-            MathArrays.shuffle(permutation, random);
+            int[] permutation = PermutationSampler.natural(10);
+            PermutationSampler.shuffle(random, permutation);
             for (int i = 0; i < 10; i++) {
                 if (i != permutation[i]) {
                     isIdentity = false;


[5/6] [math] MATH-1393: Remove functionality available in "Commons RNG".

Posted by er...@apache.org.
MATH-1393: Remove functionality available in "Commons RNG".


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/d2e40b61
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/d2e40b61
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/d2e40b61

Branch: refs/heads/master
Commit: d2e40b61f8efb9c0e3239743c6e6e2bcdb22fd7f
Parents: b0904d3
Author: Gilles <er...@apache.org>
Authored: Wed Dec 14 16:57:49 2016 +0100
Committer: Gilles <er...@apache.org>
Committed: Wed Dec 14 17:38:42 2016 +0100

----------------------------------------------------------------------
 .../commons/math4/random/JDKRandomAdaptor.java  | 148 -------------------
 .../math4/random/JDKRandomAdaptorTest.java      | 118 ---------------
 2 files changed, 266 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/d2e40b61/src/main/java/org/apache/commons/math4/random/JDKRandomAdaptor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/JDKRandomAdaptor.java b/src/main/java/org/apache/commons/math4/random/JDKRandomAdaptor.java
deleted file mode 100644
index f92d435..0000000
--- a/src/main/java/org/apache/commons/math4/random/JDKRandomAdaptor.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.random;
-
-import java.util.Random;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-import org.apache.commons.math4.exception.MathInternalError;
-import org.apache.commons.math4.exception.MathUnsupportedOperationException;
-import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.math4.distribution.RealDistribution;
-import org.apache.commons.math4.distribution.NormalDistribution;
-
-/**
- * Extension of {@link java.util.Random} that delegates the number
- * generation to a {@link UniformRandomProvider}.
- *
- * <p>
- * This class allows usage of JDK utilities that take an instance
- * of type {@code Random} as argument.
- * <br>
- * Other than for this specific purpose, usage of this class
- * is best avoided; indeed, because of the following limitations:
- * <ul>
- *  <li>
- *   {@code MathUnsupportedOperationException} will be raised if
- *   serialization is attempted.
- *  </li>
- *  <li>
- *   Reseeding is not supported.
- *  </li>
- * </ul>
- * an instance of this class cannot be a substitute for an instance
- * of the parent class if those functionalities are required.
- * </p>
- *
- * @since 4.0
- */
-public final class JDKRandomAdaptor extends Random {
-    /** Serial version identifier. */
-    private static final long serialVersionUID = 666L;
-    /** Delegate. */
-    private final transient UniformRandomProvider rng;
-    /** Cf. "nextGaussian()" method. */
-    private final transient RealDistribution.Sampler gauss;
-
-    /**
-     * Creates an adaptor.
-     *
-     * @param rng Generator.
-     */
-    public JDKRandomAdaptor(UniformRandomProvider rng) {
-        super(0L);
-
-        this.rng = rng;
-        gauss = new NormalDistribution().createSampler(rng);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public boolean nextBoolean() {
-        return rng.nextBoolean();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void nextBytes(byte[] bytes) {
-        rng.nextBytes(bytes);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public double nextDouble() {
-        return rng.nextDouble();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public float nextFloat() {
-        return rng.nextFloat();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public double nextGaussian() {
-        return gauss.sample();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public int nextInt() {
-        return rng.nextInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public int nextInt(int n) {
-        return rng.nextInt(n);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public long nextLong() {
-        return rng.nextLong();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected int next(int bits) {
-        // Should never happen: it means that some methods were not overridden.
-        throw new MathInternalError();
-    }
-
-    /**
-     * Seeding is not supported.
-     *
-     * @param seed Ignored.
-     */
-    @Override
-    public void setSeed(long seed) {
-        // Cannot throw because the constructor of "Random" calls it.
-        // throw new MathUnsupportedOperationException();
-    }
-
-    /**
-     * @param out Ignored.
-     * @throws IOException Ignored.
-     * @throws MathUnsupportedOperationException if called.
-     */
-    private void writeObject(ObjectOutputStream out)
-        throws IOException {
-        throw new MathUnsupportedOperationException();
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/d2e40b61/src/test/java/org/apache/commons/math4/random/JDKRandomAdaptorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/JDKRandomAdaptorTest.java b/src/test/java/org/apache/commons/math4/random/JDKRandomAdaptorTest.java
deleted file mode 100644
index 24b807a..0000000
--- a/src/test/java/org/apache/commons/math4/random/JDKRandomAdaptorTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.random;
-
-import java.util.Random;
-import org.apache.commons.math4.exception.MathUnsupportedOperationException;
-import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.distribution.RealDistribution;
-import org.apache.commons.math4.distribution.NormalDistribution;
-import org.apache.commons.math4.TestUtils;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test cases for {@link JDKRandomAdaptor}.
- */
-public class JDKRandomAdaptorTest {
-
-    @Test
-    public void testUniform() {
-        final RandomSource source = RandomSource.WELL_19937_C;
-        final long seed = RandomSource.createLong(); // Random seed.
-
-        final UniformRandomProvider reference = RandomSource.create(source, seed);
-        final Random random = new JDKRandomAdaptor(RandomSource.create(source, seed));
-
-        final int n = 3; // Check several times, reusing the same RNG.
-        for (int i = 0; i < n; i++) {
-            checkUniform(reference, random);
-        }
-    }
-
-    @Test
-    public void testGaussian() {
-        final RandomSource source = RandomSource.WELL_19937_C;
-        final long seed = RandomSource.createLong(); // Random seed.
-
-        final UniformRandomProvider reference = RandomSource.create(source, seed);
-        final RealDistribution.Sampler s = new NormalDistribution(0, 1).createSampler(reference);
-
-        final Random random = new JDKRandomAdaptor(RandomSource.create(source, seed));
-
-        final int n = 11; // Check several times, reusing the same RNG.
-        for (int i = 0; i < n; i++) {
-            Assert.assertEquals(s.sample(), random.nextGaussian(), 0);
-        }
-    }
-
-    @Test
-    public void testSeedIsIgnored() {
-        final RandomSource source = RandomSource.WELL_19937_C;
-        final long seed = RandomSource.createLong(); // Random seed.
-
-        Random random;
-
-        random = new JDKRandomAdaptor(RandomSource.create(source, seed));
-        final double withoutReseed = random.nextDouble();
-
-        // Same RNG.
-        random = new JDKRandomAdaptor(RandomSource.create(source, seed));
-        final long differentSeed = seed + 1;
-        random.setSeed(differentSeed); // Is seeding ignored?
-        final double withReseed = random.nextDouble();
-
-        Assert.assertEquals(withoutReseed, withReseed, 0);
-    }
-
-    @Test
-    public void testSerializeIsNotSupported() {
-        try {
-            TestUtils.serializeAndRecover(new JDKRandomAdaptor(RandomSource.create(RandomSource.WELL_512_A)));
-        } catch (Exception e) {
-            Throwable cause = e.getCause();
-            Assert.assertTrue(cause instanceof MathUnsupportedOperationException);
-        }
-    }
-
-    /**
-     * Check uniform random generator.
-     *
-     * @param rand1 Reference generator.
-     * @param rand2 Generator under test.
-     */
-    private void checkUniform(UniformRandomProvider rand1,
-                              Random rand2) {
-        final int len = 11;
-        final byte[] bytes1 = new byte[len];
-        final byte[] bytes2 = new byte[len];
-        rand1.nextBytes(bytes1);
-        rand2.nextBytes(bytes2);
-        Assert.assertArrayEquals(bytes1, bytes2);
-
-        Assert.assertEquals(rand1.nextBoolean(), rand2.nextBoolean());
-
-        Assert.assertEquals(rand1.nextInt(), rand2.nextInt());
-        Assert.assertEquals(rand1.nextInt(len), rand2.nextInt(len));
-
-        Assert.assertEquals(rand1.nextLong(), rand2.nextLong());
-
-        Assert.assertEquals(rand1.nextDouble(), rand2.nextDouble(), 0);
-        Assert.assertEquals(rand1.nextFloat(), rand2.nextFloat(), 0);
-    }
-}


[6/6] [math] Depend on "Commons RNG" (v1.0).

Posted by er...@apache.org.
Depend on "Commons RNG" (v1.0).


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/c9709dd4
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/c9709dd4
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/c9709dd4

Branch: refs/heads/master
Commit: c9709dd49d438e17ebb5bdc003b5353b0201c432
Parents: 0956e2d
Author: Gilles <er...@apache.org>
Authored: Wed Dec 14 16:51:21 2016 +0100
Committer: Gilles <er...@apache.org>
Committed: Wed Dec 14 17:38:42 2016 +0100

----------------------------------------------------------------------
 .../math4/userguide/ClusterAlgorithmComparison.java       | 10 +++++-----
 .../userguide/LowDiscrepancyGeneratorComparison.java      |  2 +-
 .../commons/math4/userguide/filter/CannonballExample.java |  2 +-
 .../math4/userguide/filter/ConstantVoltageExample.java    |  2 +-
 .../apache/commons/math4/userguide/genetics/Polygon.java  |  2 +-
 .../commons/math4/userguide/geometry/GeometryExample.java |  2 +-
 .../userguide/rng/RandomNumberGeneratorBenchmark.java     |  2 +-
 .../apache/commons/math4/userguide/sofm/ChineseRings.java |  2 +-
 .../math4/userguide/sofm/ChineseRingsClassifier.java      |  2 +-
 src/userguide/pom.xml                                     |  4 ++--
 10 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9709dd4/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java b/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
index 05d86da..f4d7de1 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/ClusterAlgorithmComparison.java
@@ -35,7 +35,8 @@ import javax.swing.JComponent;
 import javax.swing.JLabel;
 
 import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.rng.RandomSource;
+import org.apache.commons.rng.simple.RandomSource;
+import org.apache.commons.rng.sampling.ListSampler;
 
 import org.apache.commons.math4.distribution.RealDistribution;
 import org.apache.commons.math4.distribution.UniformRealDistribution;
@@ -49,7 +50,6 @@ import org.apache.commons.math4.ml.clustering.DBSCANClusterer;
 import org.apache.commons.math4.ml.clustering.DoublePoint;
 import org.apache.commons.math4.ml.clustering.FuzzyKMeansClusterer;
 import org.apache.commons.math4.ml.clustering.KMeansPlusPlusClusterer;
-import org.apache.commons.math4.random.JDKRandomAdaptor;
 import org.apache.commons.math4.random.SobolSequenceGenerator;
 import org.apache.commons.math4.util.FastMath;
 import org.apache.commons.math4.util.Pair;
@@ -85,7 +85,7 @@ public class ClusterAlgorithmComparison {
         }
         
         if (shuffle) {
-            Collections.shuffle(points, new JDKRandomAdaptor(rng));
+            ListSampler.shuffle(rng, points);
         }
 
         return points;
@@ -115,7 +115,7 @@ public class ClusterAlgorithmComparison {
         }
         
         if (shuffle) {
-            Collections.shuffle(points, new JDKRandomAdaptor(rng));
+            ListSampler.shuffle(rng, points);
         }
 
         return points;
@@ -152,7 +152,7 @@ public class ClusterAlgorithmComparison {
         }
         
         if (shuffle) {
-            Collections.shuffle(points, new JDKRandomAdaptor(rng));
+            ListSampler.shuffle(rng, points);
         }
 
         return points;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9709dd4/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java b/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
index f1b81d5..e43cba4 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/LowDiscrepancyGeneratorComparison.java
@@ -33,7 +33,7 @@ import javax.swing.JLabel;
 import javax.swing.JTextArea;
 
 import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.rng.RandomSource;
+import org.apache.commons.rng.simple.RandomSource;
 
 import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
 import org.apache.commons.math4.random.HaltonSequenceGenerator;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9709dd4/src/userguide/java/org/apache/commons/math4/userguide/filter/CannonballExample.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/filter/CannonballExample.java b/src/userguide/java/org/apache/commons/math4/userguide/filter/CannonballExample.java
index b26a489..61cea88 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/filter/CannonballExample.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/filter/CannonballExample.java
@@ -26,7 +26,7 @@ import javax.swing.JComponent;
 import javax.swing.JPanel;
 
 import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.rng.RandomSource;
+import org.apache.commons.rng.simple.RandomSource;
 
 import org.apache.commons.math4.filter.DefaultMeasurementModel;
 import org.apache.commons.math4.filter.DefaultProcessModel;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9709dd4/src/userguide/java/org/apache/commons/math4/userguide/filter/ConstantVoltageExample.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/filter/ConstantVoltageExample.java b/src/userguide/java/org/apache/commons/math4/userguide/filter/ConstantVoltageExample.java
index 2dc414f..5faccc6 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/filter/ConstantVoltageExample.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/filter/ConstantVoltageExample.java
@@ -26,7 +26,7 @@ import javax.swing.JComponent;
 import javax.swing.JPanel;
 
 import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.rng.RandomSource;
+import org.apache.commons.rng.simple.RandomSource;
 
 import org.apache.commons.math4.filter.DefaultMeasurementModel;
 import org.apache.commons.math4.filter.DefaultProcessModel;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9709dd4/src/userguide/java/org/apache/commons/math4/userguide/genetics/Polygon.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/genetics/Polygon.java b/src/userguide/java/org/apache/commons/math4/userguide/genetics/Polygon.java
index c9cf278..ae35d51 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/genetics/Polygon.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/genetics/Polygon.java
@@ -21,7 +21,7 @@ import java.awt.Graphics2D;
 import java.awt.geom.GeneralPath;
 
 import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.rng.RandomSource;
+import org.apache.commons.rng.simple.RandomSource;
 
 import org.apache.commons.math4.genetics.GeneticAlgorithm;
 import org.apache.commons.math4.util.FastMath;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9709dd4/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java b/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java
index c0aa91c..fb82522 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java
@@ -32,7 +32,7 @@ import javax.swing.JPanel;
 import javax.swing.JSplitPane;
 
 import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.rng.RandomSource;
+import org.apache.commons.rng.simple.RandomSource;
 
 import org.apache.commons.math4.geometry.enclosing.Encloser;
 import org.apache.commons.math4.geometry.enclosing.EnclosingBall;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9709dd4/src/userguide/java/org/apache/commons/math4/userguide/rng/RandomNumberGeneratorBenchmark.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/rng/RandomNumberGeneratorBenchmark.java b/src/userguide/java/org/apache/commons/math4/userguide/rng/RandomNumberGeneratorBenchmark.java
index 836e41a..acb70e1 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/rng/RandomNumberGeneratorBenchmark.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/rng/RandomNumberGeneratorBenchmark.java
@@ -20,7 +20,7 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Random;
 
-import org.apache.commons.rng.RandomSource;
+import org.apache.commons.rng.simple.RandomSource;
 import org.apache.commons.rng.UniformRandomProvider;
 
 import org.apache.commons.math4.random.RandomGenerator;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9709dd4/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java b/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java
index f906ac5..57393a6 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java
@@ -18,7 +18,7 @@
 package org.apache.commons.math4.userguide.sofm;
 
 import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.rng.RandomSource;
+import org.apache.commons.rng.simple.RandomSource;
 
 import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
 import org.apache.commons.math4.geometry.euclidean.threed.Rotation;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9709dd4/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java b/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
index 7eef617..f6a420b 100644
--- a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
+++ b/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
@@ -22,7 +22,7 @@ import java.io.PrintWriter;
 import java.io.IOException;
 
 import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.rng.RandomSource;
+import org.apache.commons.rng.simple.RandomSource;
 
 import org.apache.commons.math4.ml.neuralnet.SquareNeighbourhood;
 import org.apache.commons.math4.ml.neuralnet.FeatureInitializer;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/c9709dd4/src/userguide/pom.xml
----------------------------------------------------------------------
diff --git a/src/userguide/pom.xml b/src/userguide/pom.xml
index dfcb010..c850c92 100644
--- a/src/userguide/pom.xml
+++ b/src/userguide/pom.xml
@@ -113,8 +113,8 @@
       </dependency>
       <dependency>
           <groupId>org.apache.commons</groupId>
-          <artifactId>commons-rng</artifactId>
-          <version>1.0-SNAPSHOT</version>
+          <artifactId>commons-rng-simple</artifactId>
+          <version>1.0</version>
       </dependency>
   </dependencies>
 </project>