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/05/20 14:31:50 UTC

[1/5] [math] Javadoc.

Repository: commons-math
Updated Branches:
  refs/heads/task-MATH-1366 21cfd1006 -> 34eba8132


Javadoc.


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

Branch: refs/heads/task-MATH-1366
Commit: 4bbe9ee5bdd1c7fb210b99ed3eee720e51a3b54f
Parents: 21cfd10
Author: Gilles <er...@apache.org>
Authored: Fri May 20 13:53:54 2016 +0200
Committer: Gilles <er...@apache.org>
Committed: Fri May 20 13:53:54 2016 +0200

----------------------------------------------------------------------
 .../org/apache/commons/math4/random/RandomGeneratorFactory.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/4bbe9ee5/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java b/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java
index 1d3d71d..287b7ad 100644
--- a/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java
+++ b/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java
@@ -32,7 +32,7 @@ public class RandomGeneratorFactory {
     private RandomGeneratorFactory() {}
 
     /**
-     * Creates a {@link RandomDataGenerator} instance that wraps a
+     * Creates a {@link RandomGenerator} instance that wraps a
      * {@link Random} instance.
      *
      * @param rng JDK {@link Random} instance that will generate the


[2/5] [math] MATH-1366

Posted by er...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/7550cb46/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java b/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java
deleted file mode 100644
index d7c4906..0000000
--- a/src/test/java/org/apache/commons/math4/random/RandomDataGeneratorTest.java
+++ /dev/null
@@ -1,1212 +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.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import org.apache.commons.math4.Retry;
-import org.apache.commons.math4.RetryRunner;
-import org.apache.commons.math4.TestUtils;
-import org.apache.commons.math4.distribution.BetaDistribution;
-import org.apache.commons.math4.distribution.BinomialDistribution;
-import org.apache.commons.math4.distribution.BinomialDistributionTest;
-import org.apache.commons.math4.distribution.CauchyDistribution;
-import org.apache.commons.math4.distribution.ChiSquaredDistribution;
-import org.apache.commons.math4.distribution.ExponentialDistribution;
-import org.apache.commons.math4.distribution.FDistribution;
-import org.apache.commons.math4.distribution.GammaDistribution;
-import org.apache.commons.math4.distribution.HypergeometricDistribution;
-import org.apache.commons.math4.distribution.HypergeometricDistributionTest;
-import org.apache.commons.math4.distribution.NormalDistribution;
-import org.apache.commons.math4.distribution.PascalDistribution;
-import org.apache.commons.math4.distribution.PascalDistributionTest;
-import org.apache.commons.math4.distribution.PoissonDistribution;
-import org.apache.commons.math4.distribution.TDistribution;
-import org.apache.commons.math4.distribution.WeibullDistribution;
-import org.apache.commons.math4.distribution.ZipfDistribution;
-import org.apache.commons.math4.distribution.ZipfDistributionTest;
-import org.apache.commons.math4.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.random.RandomDataGenerator;
-import org.apache.commons.math4.stat.Frequency;
-import org.apache.commons.math4.stat.inference.ChiSquareTest;
-import org.apache.commons.math4.util.FastMath;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test cases for the RandomDataGenerator class.
- *
- */
-@RunWith(RetryRunner.class)
-public class RandomDataGeneratorTest {
-
-    public RandomDataGeneratorTest() {
-        randomData = new RandomDataGenerator();
-        randomData.reSeed(1000);
-    }
-
-    protected final long smallSampleSize = 1000;
-    protected final double[] expected = { 250, 250, 250, 250 };
-    protected final int largeSampleSize = 10000;
-    private final String[] hex = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
-            "a", "b", "c", "d", "e", "f" };
-    protected RandomDataGenerator randomData = null;
-    protected final ChiSquareTest testStatistic = new ChiSquareTest();
-
-    @Test
-    public void testNextIntExtremeValues() {
-        int x = randomData.nextInt(Integer.MIN_VALUE, Integer.MAX_VALUE);
-        int y = randomData.nextInt(Integer.MIN_VALUE, Integer.MAX_VALUE);
-        Assert.assertFalse(x == y);
-    }
-
-    @Test
-    public void testNextLongExtremeValues() {
-        long x = randomData.nextLong(Long.MIN_VALUE, Long.MAX_VALUE);
-        long y = randomData.nextLong(Long.MIN_VALUE, Long.MAX_VALUE);
-        Assert.assertFalse(x == y);
-    }
-
-    @Test
-    public void testNextUniformExtremeValues() {
-        double x = randomData.nextUniform(-Double.MAX_VALUE, Double.MAX_VALUE);
-        double y = randomData.nextUniform(-Double.MAX_VALUE, Double.MAX_VALUE);
-        Assert.assertFalse(x == y);
-        Assert.assertFalse(Double.isNaN(x));
-        Assert.assertFalse(Double.isNaN(y));
-        Assert.assertFalse(Double.isInfinite(x));
-        Assert.assertFalse(Double.isInfinite(y));
-    }
-
-    @Test
-    public void testNextIntIAE() {
-        try {
-            randomData.nextInt(4, 3);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-    }
-
-    @Test
-    public void testNextIntNegativeToPositiveRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextIntUniform(-3, 5);
-            checkNextIntUniform(-3, 6);
-        }
-    }
-
-    @Test
-    public void testNextIntNegativeRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextIntUniform(-7, -4);
-            checkNextIntUniform(-15, -2);
-            checkNextIntUniform(Integer.MIN_VALUE + 1, Integer.MIN_VALUE + 12);
-        }
-    }
-
-    @Test
-    public void testNextIntPositiveRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextIntUniform(0, 3);
-            checkNextIntUniform(2, 12);
-            checkNextIntUniform(1,2);
-            checkNextIntUniform(Integer.MAX_VALUE - 12, Integer.MAX_VALUE - 1);
-        }
-    }
-
-    private void checkNextIntUniform(int min, int max) {
-        final Frequency freq = new Frequency();
-        for (int i = 0; i < smallSampleSize; i++) {
-            final int value = randomData.nextInt(min, max);
-            Assert.assertTrue("nextInt range", (value >= min) && (value <= max));
-            freq.addValue(value);
-        }
-        final int len = max - min + 1;
-        final long[] observed = new long[len];
-        for (int i = 0; i < len; i++) {
-            observed[i] = freq.getCount(min + i);
-        }
-        final double[] expected = new double[len];
-        for (int i = 0; i < len; i++) {
-            expected[i] = 1d / len;
-        }
-
-        TestUtils.assertChiSquareAccept(expected, observed, 0.001);
-    }
-
-    @Test
-    public void testNextIntWideRange() {
-        int lower = -0x6543210F;
-        int upper =  0x456789AB;
-        int max   = Integer.MIN_VALUE;
-        int min   = Integer.MAX_VALUE;
-        for (int i = 0; i < 1000000; ++i) {
-            int r = randomData.nextInt(lower, upper);
-            max = FastMath.max(max, r);
-            min = FastMath.min(min, r);
-            Assert.assertTrue(r >= lower);
-            Assert.assertTrue(r <= upper);
-        }
-        double ratio = (((double) max)   - ((double) min)) /
-                       (((double) upper) - ((double) lower));
-        Assert.assertTrue(ratio > 0.99999);
-    }
-
-    @Test
-    public void testNextLongIAE() {
-        try {
-            randomData.nextLong(4, 3);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-    }
-
-    @Test
-    public void testNextLongNegativeToPositiveRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextLongUniform(-3, 5);
-            checkNextLongUniform(-3, 6);
-        }
-    }
-
-    @Test
-    public void testNextLongNegativeRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextLongUniform(-7, -4);
-            checkNextLongUniform(-15, -2);
-            checkNextLongUniform(Long.MIN_VALUE + 1, Long.MIN_VALUE + 12);
-        }
-    }
-
-    @Test
-    public void testNextLongPositiveRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextLongUniform(0, 3);
-            checkNextLongUniform(2, 12);
-            checkNextLongUniform(Long.MAX_VALUE - 12, Long.MAX_VALUE - 1);
-        }
-    }
-
-    private void checkNextLongUniform(long min, long max) {
-        final Frequency freq = new Frequency();
-        for (int i = 0; i < smallSampleSize; i++) {
-            final long value = randomData.nextLong(min, max);
-            Assert.assertTrue("nextLong range: " + value + " " + min + " " + max,
-                              (value >= min) && (value <= max));
-            freq.addValue(value);
-        }
-        final int len = ((int) (max - min)) + 1;
-        final long[] observed = new long[len];
-        for (int i = 0; i < len; i++) {
-            observed[i] = freq.getCount(min + i);
-        }
-        final double[] expected = new double[len];
-        for (int i = 0; i < len; i++) {
-            expected[i] = 1d / len;
-        }
-
-        TestUtils.assertChiSquareAccept(expected, observed, 0.01);
-    }
-
-    @Test
-    public void testNextLongWideRange() {
-        long lower = -0x6543210FEDCBA987L;
-        long upper =  0x456789ABCDEF0123L;
-        long max = Long.MIN_VALUE;
-        long min = Long.MAX_VALUE;
-        for (int i = 0; i < 10000000; ++i) {
-            long r = randomData.nextLong(lower, upper);
-            max = FastMath.max(max, r);
-            min = FastMath.min(min, r);
-            Assert.assertTrue(r >= lower);
-            Assert.assertTrue(r <= upper);
-        }
-        double ratio = (((double) max)   - ((double) min)) /
-                       (((double) upper) - ((double) lower));
-        Assert.assertTrue(ratio > 0.99999);
-    }
-
-    @Test
-    public void testNextSecureLongIAE() {
-        try {
-            randomData.nextSecureLong(4, 3);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-    }
-
-    @Test
-    @Retry(3)
-    public void testNextSecureLongNegativeToPositiveRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextSecureLongUniform(-3, 5);
-            checkNextSecureLongUniform(-3, 6);
-        }
-    }
-
-    @Test
-    @Retry(3)
-    public void testNextSecureLongNegativeRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextSecureLongUniform(-7, -4);
-            checkNextSecureLongUniform(-15, -2);
-        }
-    }
-
-    @Test
-    @Retry(3)
-    public void testNextSecureLongPositiveRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextSecureLongUniform(0, 3);
-            checkNextSecureLongUniform(2, 12);
-        }
-    }
-
-    private void checkNextSecureLongUniform(int min, int max) {
-        final Frequency freq = new Frequency();
-        for (int i = 0; i < smallSampleSize; i++) {
-            final long value = randomData.nextSecureLong(min, max);
-            Assert.assertTrue("nextLong range", (value >= min) && (value <= max));
-            freq.addValue(value);
-        }
-        final int len = max - min + 1;
-        final long[] observed = new long[len];
-        for (int i = 0; i < len; i++) {
-            observed[i] = freq.getCount(min + i);
-        }
-        final double[] expected = new double[len];
-        for (int i = 0; i < len; i++) {
-            expected[i] = 1d / len;
-        }
-
-        TestUtils.assertChiSquareAccept(expected, observed, 0.0001);
-    }
-
-    @Test
-    public void testNextSecureIntIAE() {
-        try {
-            randomData.nextSecureInt(4, 3);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-    }
-
-    @Test
-    @Retry(3)
-    public void testNextSecureIntNegativeToPositiveRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextSecureIntUniform(-3, 5);
-            checkNextSecureIntUniform(-3, 6);
-        }
-    }
-
-    @Test
-    @Retry(3)
-    public void testNextSecureIntNegativeRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextSecureIntUniform(-7, -4);
-            checkNextSecureIntUniform(-15, -2);
-        }
-    }
-
-    @Test
-    @Retry(3)
-    public void testNextSecureIntPositiveRange() {
-        for (int i = 0; i < 5; i++) {
-            checkNextSecureIntUniform(0, 3);
-            checkNextSecureIntUniform(2, 12);
-        }
-    }
-
-    private void checkNextSecureIntUniform(int min, int max) {
-        final Frequency freq = new Frequency();
-        for (int i = 0; i < smallSampleSize; i++) {
-            final int value = randomData.nextSecureInt(min, max);
-            Assert.assertTrue("nextInt range", (value >= min) && (value <= max));
-            freq.addValue(value);
-        }
-        final int len = max - min + 1;
-        final long[] observed = new long[len];
-        for (int i = 0; i < len; i++) {
-            observed[i] = freq.getCount(min + i);
-        }
-        final double[] expected = new double[len];
-        for (int i = 0; i < len; i++) {
-            expected[i] = 1d / len;
-        }
-
-        TestUtils.assertChiSquareAccept(expected, observed, 0.0001);
-    }
-
-
-
-    /**
-     * Make sure that empirical distribution of random Poisson(4)'s has P(X <=
-     * 5) close to actual cumulative Poisson probability and that nextPoisson
-     * fails when mean is non-positive.
-     */
-    @Test
-    public void testNextPoisson() {
-        try {
-            randomData.nextPoisson(0);
-            Assert.fail("zero mean -- expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextPoisson(-1);
-            Assert.fail("negative mean supplied -- MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextPoisson(0);
-            Assert.fail("0 mean supplied -- MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-
-        final double mean = 4.0d;
-        final int len = 5;
-        PoissonDistribution poissonDistribution = new PoissonDistribution(mean);
-        Frequency f = new Frequency();
-        randomData.reSeed(1000);
-        for (int i = 0; i < largeSampleSize; i++) {
-            f.addValue(randomData.nextPoisson(mean));
-        }
-        final long[] observed = new long[len];
-        for (int i = 0; i < len; i++) {
-            observed[i] = f.getCount(i + 1);
-        }
-        final double[] expected = new double[len];
-        for (int i = 0; i < len; i++) {
-            expected[i] = poissonDistribution.probability(i + 1) * largeSampleSize;
-        }
-
-        TestUtils.assertChiSquareAccept(expected, observed, 0.0001);
-    }
-
-    @Test
-    public void testNextPoissonConsistency() {
-
-        // Small integral means
-        for (int i = 1; i < 100; i++) {
-            checkNextPoissonConsistency(i);
-        }
-        // non-integer means
-        for (int i = 1; i < 10; i++) {
-            checkNextPoissonConsistency(randomData.nextUniform(1, 1000));
-        }
-        // large means
-        for (int i = 1; i < 10; i++) {
-            checkNextPoissonConsistency(randomData.nextUniform(1000, 10000));
-        }
-    }
-
-    /**
-     * Verifies that nextPoisson(mean) generates an empirical distribution of values
-     * consistent with PoissonDistributionImpl by generating 1000 values, computing a
-     * grouped frequency distribution of the observed values and comparing this distribution
-     * to the corresponding expected distribution computed using PoissonDistributionImpl.
-     * Uses ChiSquare test of goodness of fit to evaluate the null hypothesis that the
-     * distributions are the same. If the null hypothesis can be rejected with confidence
-     * 1 - alpha, the check fails.
-     */
-    public void checkNextPoissonConsistency(double mean) {
-        // Generate sample values
-        final int sampleSize = 1000;        // Number of deviates to generate
-        final int minExpectedCount = 7;     // Minimum size of expected bin count
-        long maxObservedValue = 0;
-        final double alpha = 0.001;         // Probability of false failure
-        Frequency frequency = new Frequency();
-        for (int i = 0; i < sampleSize; i++) {
-            long value = randomData.nextPoisson(mean);
-            if (value > maxObservedValue) {
-                maxObservedValue = value;
-            }
-            frequency.addValue(value);
-        }
-
-        /*
-         *  Set up bins for chi-square test.
-         *  Ensure expected counts are all at least minExpectedCount.
-         *  Start with upper and lower tail bins.
-         *  Lower bin = [0, lower); Upper bin = [upper, +inf).
-         */
-        PoissonDistribution poissonDistribution = new PoissonDistribution(mean);
-        int lower = 1;
-        while (poissonDistribution.cumulativeProbability(lower - 1) * sampleSize < minExpectedCount) {
-            lower++;
-        }
-        int upper = (int) (5 * mean);  // Even for mean = 1, not much mass beyond 5
-        while ((1 - poissonDistribution.cumulativeProbability(upper - 1)) * sampleSize < minExpectedCount) {
-            upper--;
-        }
-
-        // Set bin width for interior bins.  For poisson, only need to look at end bins.
-        int binWidth = 0;
-        boolean widthSufficient = false;
-        double lowerBinMass = 0;
-        double upperBinMass = 0;
-        while (!widthSufficient) {
-            binWidth++;
-            lowerBinMass = poissonDistribution.probability(lower - 1, lower + binWidth - 1);
-            upperBinMass = poissonDistribution.probability(upper - binWidth - 1, upper - 1);
-            widthSufficient = FastMath.min(lowerBinMass, upperBinMass) * sampleSize >= minExpectedCount;
-        }
-
-        /*
-         *  Determine interior bin bounds.  Bins are
-         *  [1, lower = binBounds[0]), [lower, binBounds[1]), [binBounds[1], binBounds[2]), ... ,
-         *    [binBounds[binCount - 2], upper = binBounds[binCount - 1]), [upper, +inf)
-         *
-         */
-        List<Integer> binBounds = new ArrayList<Integer>();
-        binBounds.add(lower);
-        int bound = lower + binWidth;
-        while (bound < upper - binWidth) {
-            binBounds.add(bound);
-            bound += binWidth;
-        }
-        binBounds.add(upper); // The size of bin [binBounds[binCount - 2], upper) satisfies binWidth <= size < 2*binWidth.
-
-        // Compute observed and expected bin counts
-        final int binCount = binBounds.size() + 1;
-        long[] observed = new long[binCount];
-        double[] expected = new double[binCount];
-
-        // Bottom bin
-        observed[0] = 0;
-        for (int i = 0; i < lower; i++) {
-            observed[0] += frequency.getCount(i);
-        }
-        expected[0] = poissonDistribution.cumulativeProbability(lower - 1) * sampleSize;
-
-        // Top bin
-        observed[binCount - 1] = 0;
-        for (int i = upper; i <= maxObservedValue; i++) {
-            observed[binCount - 1] += frequency.getCount(i);
-        }
-        expected[binCount - 1] = (1 - poissonDistribution.cumulativeProbability(upper - 1)) * sampleSize;
-
-        // Interior bins
-        for (int i = 1; i < binCount - 1; i++) {
-            observed[i] = 0;
-            for (int j = binBounds.get(i - 1); j < binBounds.get(i); j++) {
-                observed[i] += frequency.getCount(j);
-            } // Expected count is (mass in [binBounds[i-1], binBounds[i])) * sampleSize
-            expected[i] = (poissonDistribution.cumulativeProbability(binBounds.get(i) - 1) -
-                poissonDistribution.cumulativeProbability(binBounds.get(i - 1) -1)) * sampleSize;
-        }
-
-        // Use chisquare test to verify that generated values are poisson(mean)-distributed
-        ChiSquareTest chiSquareTest = new ChiSquareTest();
-            // Fail if we can reject null hypothesis that distributions are the same
-        if (chiSquareTest.chiSquareTest(expected, observed, alpha)) {
-            StringBuilder msgBuffer = new StringBuilder();
-            DecimalFormat df = new DecimalFormat("#.##");
-            msgBuffer.append("Chisquare test failed for mean = ");
-            msgBuffer.append(mean);
-            msgBuffer.append(" p-value = ");
-            msgBuffer.append(chiSquareTest.chiSquareTest(expected, observed));
-            msgBuffer.append(" chisquare statistic = ");
-            msgBuffer.append(chiSquareTest.chiSquare(expected, observed));
-            msgBuffer.append(". \n");
-            msgBuffer.append("bin\t\texpected\tobserved\n");
-            for (int i = 0; i < expected.length; i++) {
-                msgBuffer.append("[");
-                msgBuffer.append(i == 0 ? 1: binBounds.get(i - 1));
-                msgBuffer.append(",");
-                msgBuffer.append(i == binBounds.size() ? "inf": binBounds.get(i));
-                msgBuffer.append(")");
-                msgBuffer.append("\t\t");
-                msgBuffer.append(df.format(expected[i]));
-                msgBuffer.append("\t\t");
-                msgBuffer.append(observed[i]);
-                msgBuffer.append("\n");
-            }
-            msgBuffer.append("This test can fail randomly due to sampling error with probability ");
-            msgBuffer.append(alpha);
-            msgBuffer.append(".");
-            Assert.fail(msgBuffer.toString());
-        }
-    }
-
-    /** test dispersion and failure modes for nextHex() */
-    @Test
-    public void testNextHex() {
-        try {
-            randomData.nextHexString(-1);
-            Assert.fail("negative length supplied -- MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextHexString(0);
-            Assert.fail("zero length supplied -- MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        String hexString = randomData.nextHexString(3);
-        if (hexString.length() != 3) {
-            Assert.fail("incorrect length for generated string");
-        }
-        hexString = randomData.nextHexString(1);
-        if (hexString.length() != 1) {
-            Assert.fail("incorrect length for generated string");
-        }
-        try {
-            hexString = randomData.nextHexString(0);
-            Assert.fail("zero length requested -- expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        Frequency f = new Frequency();
-        for (int i = 0; i < smallSampleSize; i++) {
-            hexString = randomData.nextHexString(100);
-            if (hexString.length() != 100) {
-                Assert.fail("incorrect length for generated string");
-            }
-            for (int j = 0; j < hexString.length(); j++) {
-                f.addValue(hexString.substring(j, j + 1));
-            }
-        }
-        double[] expected = new double[16];
-        long[] observed = new long[16];
-        for (int i = 0; i < 16; i++) {
-            expected[i] = (double) smallSampleSize * 100 / 16;
-            observed[i] = f.getCount(hex[i]);
-        }
-        TestUtils.assertChiSquareAccept(expected, observed, 0.001);
-    }
-
-    /** test dispersion and failure modes for nextHex() */
-    @Test
-    @Retry(3)
-    public void testNextSecureHex() {
-        try {
-            randomData.nextSecureHexString(-1);
-            Assert.fail("negative length -- MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextSecureHexString(0);
-            Assert.fail("zero length -- MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        String hexString = randomData.nextSecureHexString(3);
-        if (hexString.length() != 3) {
-            Assert.fail("incorrect length for generated string");
-        }
-        hexString = randomData.nextSecureHexString(1);
-        if (hexString.length() != 1) {
-            Assert.fail("incorrect length for generated string");
-        }
-        try {
-            hexString = randomData.nextSecureHexString(0);
-            Assert.fail("zero length requested -- expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        Frequency f = new Frequency();
-        for (int i = 0; i < smallSampleSize; i++) {
-            hexString = randomData.nextSecureHexString(100);
-            if (hexString.length() != 100) {
-                Assert.fail("incorrect length for generated string");
-            }
-            for (int j = 0; j < hexString.length(); j++) {
-                f.addValue(hexString.substring(j, j + 1));
-            }
-        }
-        double[] expected = new double[16];
-        long[] observed = new long[16];
-        for (int i = 0; i < 16; i++) {
-            expected[i] = (double) smallSampleSize * 100 / 16;
-            observed[i] = f.getCount(hex[i]);
-        }
-        TestUtils.assertChiSquareAccept(expected, observed, 0.001);
-    }
-
-    @Test
-    public void testNextUniformIAE() {
-        try {
-            randomData.nextUniform(4, 3);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextUniform(0, Double.POSITIVE_INFINITY);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextUniform(Double.NEGATIVE_INFINITY, 0);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextUniform(0, Double.NaN);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextUniform(Double.NaN, 0);
-            Assert.fail("MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-    }
-
-    @Test
-    public void testNextUniformUniformPositiveBounds() {
-        for (int i = 0; i < 5; i++) {
-            checkNextUniformUniform(0, 10);
-        }
-    }
-
-    @Test
-    public void testNextUniformUniformNegativeToPositiveBounds() {
-        for (int i = 0; i < 5; i++) {
-            checkNextUniformUniform(-3, 5);
-        }
-    }
-
-    @Test
-    public void testNextUniformUniformNegaiveBounds() {
-        for (int i = 0; i < 5; i++) {
-            checkNextUniformUniform(-7, -3);
-        }
-    }
-
-    @Test
-    public void testNextUniformUniformMaximalInterval() {
-        for (int i = 0; i < 5; i++) {
-            checkNextUniformUniform(-Double.MAX_VALUE, Double.MAX_VALUE);
-        }
-    }
-
-    private void checkNextUniformUniform(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
-        final double[] binBounds = new double[binCount - 1];
-        binBounds[0] = min + binSize;
-        for (int i = 1; i < binCount - 1; i++) {
-            binBounds[i] = binBounds[i - 1] + binSize;  // + instead of * to avoid overflow in extreme case
-        }
-
-        final Frequency freq = new Frequency();
-        for (int i = 0; i < smallSampleSize; i++) {
-            final double value = randomData.nextUniform(min, max);
-            Assert.assertTrue("nextUniform range", (value > min) && (value < max));
-            // Find bin
-            int j = 0;
-            while (j < binCount - 1 && value > binBounds[j]) {
-                j++;
-            }
-            freq.addValue(j);
-        }
-
-        final long[] observed = new long[binCount];
-        for (int i = 0; i < binCount; i++) {
-            observed[i] = freq.getCount(i);
-        }
-        final double[] expected = new double[binCount];
-        for (int i = 0; i < binCount; i++) {
-            expected[i] = 1d / binCount;
-        }
-
-        TestUtils.assertChiSquareAccept(expected, observed, 0.01);
-    }
-
-    /** test exclusive endpoints of nextUniform **/
-    @Test
-    public void testNextUniformExclusiveEndpoints() {
-        for (int i = 0; i < 1000; i++) {
-            double u = randomData.nextUniform(0.99, 1);
-            Assert.assertTrue(u > 0.99 && u < 1);
-        }
-    }
-
-    /** test failure modes and distribution of nextGaussian() */
-    @Test
-    public void testNextGaussian() {
-        try {
-            randomData.nextGaussian(0, 0);
-            Assert.fail("zero sigma -- MathIllegalArgumentException expected");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        double[] quartiles = TestUtils.getDistributionQuartiles(new NormalDistribution(0,1));
-        long[] counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextGaussian(0, 1);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-    }
-
-    /** test failure modes and distribution of nextExponential() */
-    @Test
-    public void testNextExponential() {
-        try {
-            randomData.nextExponential(-1);
-            Assert.fail("negative mean -- expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        try {
-            randomData.nextExponential(0);
-            Assert.fail("zero mean -- expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-        double[] quartiles;
-        long[] counts;
-
-        // Mean 1
-        quartiles = TestUtils.getDistributionQuartiles(new ExponentialDistribution(1));
-        counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextExponential(1);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-
-        // Mean 5
-        quartiles = TestUtils.getDistributionQuartiles(new ExponentialDistribution(5));
-        counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextExponential(5);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-    }
-
-    /** test reseeding, algorithm/provider games */
-    @Test
-    public void testConfig() {
-        randomData.reSeed(1000);
-        double v = randomData.nextUniform(0, 1);
-        randomData.reSeed();
-        Assert.assertTrue("different seeds", FastMath.abs(v - randomData.nextUniform(0, 1)) > 10E-12);
-        randomData.reSeed(1000);
-        Assert.assertEquals("same seeds", v, randomData.nextUniform(0, 1), 10E-12);
-        randomData.reSeedSecure(1000);
-        String hex = randomData.nextSecureHexString(40);
-        randomData.reSeedSecure();
-        Assert.assertTrue("different seeds", !hex.equals(randomData
-                .nextSecureHexString(40)));
-        randomData.reSeedSecure(1000);
-        Assert.assertTrue("same seeds", !hex
-                .equals(randomData.nextSecureHexString(40)));
-
-        /*
-         * remove this test back soon, since it takes about 4 seconds
-         *
-         * try { randomData.setSecureAlgorithm("SHA1PRNG","SUN"); } catch
-         * (NoSuchProviderException ex) { ; } Assert.assertTrue("different seeds",
-         * !hex.equals(randomData.nextSecureHexString(40))); try {
-         * randomData.setSecureAlgorithm("NOSUCHTHING","SUN");
-         * Assert.fail("expecting NoSuchAlgorithmException"); } catch
-         * (NoSuchProviderException ex) { ; } catch (NoSuchAlgorithmException
-         * ex) { ; }
-         *
-         * try { randomData.setSecureAlgorithm("SHA1PRNG","NOSUCHPROVIDER");
-         * Assert.fail("expecting NoSuchProviderException"); } catch
-         * (NoSuchProviderException ex) { ; }
-         */
-
-        // test reseeding without first using the generators
-        RandomDataGenerator rd = new RandomDataGenerator();
-        rd.reSeed(100);
-        rd.nextLong(1, 2);
-        RandomDataGenerator rd2 = new RandomDataGenerator();
-        rd2.reSeedSecure(2000);
-        rd2.nextSecureLong(1, 2);
-        rd = new RandomDataGenerator();
-        rd.reSeed();
-        rd.nextLong(1, 2);
-        rd2 = new RandomDataGenerator();
-        rd2.reSeedSecure();
-        rd2.nextSecureLong(1, 2);
-    }
-
-    /** 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<Object>(); // {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<Object>();
-            hs.add(c[i][0]);
-            hs.add(c[i][1]);
-            sets[i] = hs;
-        }
-
-        for (int i = 0; i < 1000; i++) {
-            Object[] cSamp = randomData.nextSample(cPop, 2);
-            observed[findSample(sets, cSamp)]++;
-        }
-
-        /*
-         * Use ChiSquare dist with df = 10-1 = 9, alpha = .001 Change to 21.67
-         * for alpha = .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<Object>();
-        hs.add("one");
-        Object[] one = randomData.nextSample(hs, 1);
-        String oneString = (String) one[0];
-        if ((one.length != 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<Object>();
-            one = randomData.nextSample(hs, 0);
-            Assert.fail("n = k = 0, expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // ignored
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private int findSample(Object[] u, Object[] samp) {
-        for (int i = 0; i < u.length; i++) {
-            HashSet<Object> set = (HashSet<Object>) u[i];
-            HashSet<Object> sampSet = new HashSet<Object>();
-            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
-            }
-
-        }
-    }
-
-    // Disable until we have equals
-    //public void testSerial() {
-    //    Assert.assertEquals(randomData, TestUtils.serializeAndRecover(randomData));
-    //}
-
-    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;
-    }
-
-    @Test
-    public void testNextBeta() {
-        double[] quartiles = TestUtils.getDistributionQuartiles(new BetaDistribution(2,5));
-        long[] counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextBeta(2, 5);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-    }
-
-    @Test
-    public void testNextCauchy() {
-        double[] quartiles = TestUtils.getDistributionQuartiles(new CauchyDistribution(1.2, 2.1));
-        long[] counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextCauchy(1.2, 2.1);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-    }
-
-    @Test
-    public void testNextChiSquare() {
-        double[] quartiles = TestUtils.getDistributionQuartiles(new ChiSquaredDistribution(12));
-        long[] counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextChiSquare(12);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-    }
-
-    @Test
-    public void testNextF() {
-        double[] quartiles = TestUtils.getDistributionQuartiles(new FDistribution(12, 5));
-        long[] counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextF(12, 5);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-    }
-
-    @Test
-    public void testNextGamma() {
-        double[] quartiles;
-        long[] counts;
-
-        // Tests shape > 1, one case in the rejection sampling
-        quartiles = TestUtils.getDistributionQuartiles(new GammaDistribution(4, 2));
-        counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextGamma(4, 2);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-
-        // Tests shape <= 1, another case in the rejection sampling
-        quartiles = TestUtils.getDistributionQuartiles(new GammaDistribution(0.3, 3));
-        counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextGamma(0.3, 3);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-    }
-
-    @Test
-    public void testNextT() {
-        double[] quartiles = TestUtils.getDistributionQuartiles(new TDistribution(10));
-        long[] counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextT(10);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-    }
-
-    @Test
-    public void testNextWeibull() {
-        double[] quartiles = TestUtils.getDistributionQuartiles(new WeibullDistribution(1.2, 2.1));
-        long[] counts = new long[4];
-        randomData.reSeed(1000);
-        for (int i = 0; i < 1000; i++) {
-            double value = randomData.nextWeibull(1.2, 2.1);
-            TestUtils.updateCounts(value, counts, quartiles);
-        }
-        TestUtils.assertChiSquareAccept(expected, counts, 0.001);
-    }
-
-    @Test
-    public void testNextBinomial() {
-        BinomialDistributionTest testInstance = new BinomialDistributionTest();
-        int[] densityPoints = testInstance.makeDensityTestPoints();
-        double[] densityValues = testInstance.makeDensityTestValues();
-        int sampleSize = 1000;
-        int length = TestUtils.eliminateZeroMassPoints(densityPoints, densityValues);
-        BinomialDistribution distribution = (BinomialDistribution) testInstance.makeDistribution();
-        double[] expectedCounts = new double[length];
-        long[] observedCounts = new long[length];
-        for (int i = 0; i < length; i++) {
-            expectedCounts[i] = sampleSize * densityValues[i];
-        }
-        randomData.reSeed(1000);
-        for (int i = 0; i < sampleSize; i++) {
-          int value = randomData.nextBinomial(distribution.getNumberOfTrials(),
-                  distribution.getProbabilityOfSuccess());
-          for (int j = 0; j < length; j++) {
-              if (value == densityPoints[j]) {
-                  observedCounts[j]++;
-              }
-          }
-        }
-        TestUtils.assertChiSquareAccept(densityPoints, expectedCounts, observedCounts, .001);
-    }
-
-    @Test
-    public void testNextHypergeometric() {
-        HypergeometricDistributionTest testInstance = new HypergeometricDistributionTest();
-        int[] densityPoints = testInstance.makeDensityTestPoints();
-        double[] densityValues = testInstance.makeDensityTestValues();
-        int sampleSize = 1000;
-        int length = TestUtils.eliminateZeroMassPoints(densityPoints, densityValues);
-        HypergeometricDistribution distribution = (HypergeometricDistribution) testInstance.makeDistribution();
-        double[] expectedCounts = new double[length];
-        long[] observedCounts = new long[length];
-        for (int i = 0; i < length; i++) {
-            expectedCounts[i] = sampleSize * densityValues[i];
-        }
-        randomData.reSeed(1000);
-        for (int i = 0; i < sampleSize; i++) {
-          int value = randomData.nextHypergeometric(distribution.getPopulationSize(),
-                  distribution.getNumberOfSuccesses(), distribution.getSampleSize());
-          for (int j = 0; j < length; j++) {
-              if (value == densityPoints[j]) {
-                  observedCounts[j]++;
-              }
-          }
-        }
-        TestUtils.assertChiSquareAccept(densityPoints, expectedCounts, observedCounts, .001);
-    }
-
-    @Test
-    public void testNextPascal() {
-        PascalDistributionTest testInstance = new PascalDistributionTest();
-        int[] densityPoints = testInstance.makeDensityTestPoints();
-        double[] densityValues = testInstance.makeDensityTestValues();
-        int sampleSize = 1000;
-        int length = TestUtils.eliminateZeroMassPoints(densityPoints, densityValues);
-        PascalDistribution distribution = (PascalDistribution) testInstance.makeDistribution();
-        double[] expectedCounts = new double[length];
-        long[] observedCounts = new long[length];
-        for (int i = 0; i < length; i++) {
-            expectedCounts[i] = sampleSize * densityValues[i];
-        }
-        randomData.reSeed(1000);
-        for (int i = 0; i < sampleSize; i++) {
-          int value = randomData.nextPascal(distribution.getNumberOfSuccesses(), distribution.getProbabilityOfSuccess());
-          for (int j = 0; j < length; j++) {
-              if (value == densityPoints[j]) {
-                  observedCounts[j]++;
-              }
-          }
-        }
-        TestUtils.assertChiSquareAccept(densityPoints, expectedCounts, observedCounts, .001);
-    }
-
-    @Test
-    public void testNextZipf() {
-        ZipfDistributionTest testInstance = new ZipfDistributionTest();
-        int[] densityPoints = testInstance.makeDensityTestPoints();
-        double[] densityValues = testInstance.makeDensityTestValues();
-        int sampleSize = 1000;
-        int length = TestUtils.eliminateZeroMassPoints(densityPoints, densityValues);
-        ZipfDistribution distribution = (ZipfDistribution) testInstance.makeDistribution();
-        double[] expectedCounts = new double[length];
-        long[] observedCounts = new long[length];
-        for (int i = 0; i < length; i++) {
-            expectedCounts[i] = sampleSize * densityValues[i];
-        }
-        randomData.reSeed(1000);
-        for (int i = 0; i < sampleSize; i++) {
-          int value = randomData.nextZipf(distribution.getNumberOfElements(), distribution.getExponent());
-          for (int j = 0; j < length; j++) {
-              if (value == densityPoints[j]) {
-                  observedCounts[j]++;
-              }
-          }
-        }
-        TestUtils.assertChiSquareAccept(densityPoints, expectedCounts, observedCounts, .001);
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/7550cb46/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java b/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java
deleted file mode 100644
index f4ddfbd..0000000
--- a/src/test/java/org/apache/commons/math4/random/RandomGeneratorAbstractTest.java
+++ /dev/null
@@ -1,462 +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.Arrays;
-
-import org.apache.commons.math4.TestUtils;
-import org.apache.commons.math4.distribution.RealDistribution;
-import org.apache.commons.math4.distribution.UniformRealDistribution;
-import org.apache.commons.math4.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.stat.Frequency;
-import org.apache.commons.math4.stat.inference.KolmogorovSmirnovTest;
-import org.apache.commons.math4.util.FastMath;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Base class for RandomGenerator tests.
- *
- * Tests RandomGenerator methods directly and also executes RandomDataTest
- * test cases against a RandomDataImpl created using the provided generator.
- *
- * RandomGenerator test classes should extend this class, implementing
- * makeGenerator() to provide a concrete generator to test. The generator
- * returned by makeGenerator should be seeded with a fixed seed.
- *
- */
-
-public abstract class RandomGeneratorAbstractTest extends RandomDataGeneratorTest {
-
-    /** RandomGenerator under test */
-    protected RandomGenerator generator;
-
-    /**
-     * Override this method in subclasses to provide a concrete generator to test.
-     * Return a generator seeded with a fixed seed.
-     */
-    protected abstract RandomGenerator makeGenerator();
-
-    /**
-     * Initialize generator and randomData instance in superclass.
-     */
-    public RandomGeneratorAbstractTest() {
-        generator = makeGenerator();
-        randomData = new RandomDataGenerator(generator);
-    }
-
-    /**
-     * Set a fixed seed for the tests
-     */
-    @Before
-    public void setUp() {
-        generator = makeGenerator();
-    }
-
-    // Omit secureXxx tests, since they do not use the provided generator
-    @Override
-    public void testNextSecureLongIAE() {}
-    @Override
-    public void testNextSecureLongNegativeToPositiveRange() {}
-    @Override
-    public void testNextSecureLongNegativeRange() {}
-    @Override
-    public void testNextSecureLongPositiveRange() {}
-    @Override
-    public void testNextSecureIntIAE() {}
-    @Override
-    public void testNextSecureIntNegativeToPositiveRange() {}
-    @Override
-    public void testNextSecureIntNegativeRange() {}
-    @Override
-    public void testNextSecureIntPositiveRange() {}
-    @Override
-    public void testNextSecureHex() {}
-
-    @Test
-    /**
-     * Tests uniformity of nextInt(int) distribution by generating 1000
-     * samples for each of 10 test values and for each sample performing
-     * a chi-square test of homogeneity of the observed distribution with
-     * the expected uniform distribution.  Tests are performed at the .01
-     * level and an average failure rate higher than 2% (i.e. more than 20
-     * null hypothesis rejections) causes the test case to fail.
-     *
-     * All random values are generated using the generator instance used by
-     * other tests and the generator is not reseeded, so this is a fixed seed
-     * test.
-     */
-    public void testNextIntDirect() {
-        // Set up test values - end of the array filled randomly
-        int[] testValues = new int[] {4, 10, 12, 32, 100, 10000, 0, 0, 0, 0};
-        for (int i = 6; i < 10; i++) {
-            final int val = generator.nextInt();
-            testValues[i] = val < 0 ? -val : val + 1;
-        }
-
-        final int numTests = 1000;
-        for (int i = 0; i < testValues.length; i++) {
-            final int n = testValues[i];
-            // Set up bins
-            int[] binUpperBounds;
-            if (n < 32) {
-                binUpperBounds = new int[n];
-                for (int k = 0; k < n; k++) {
-                    binUpperBounds[k] = k;
-                }
-            } else {
-                binUpperBounds = new int[10];
-                final int step = n / 10;
-                for (int k = 0; k < 9; k++) {
-                    binUpperBounds[k] = (k + 1) * step;
-                }
-                binUpperBounds[9] = n - 1;
-            }
-            // Run the tests
-            int numFailures = 0;
-            final int binCount = binUpperBounds.length;
-            final long[] observed = new long[binCount];
-            final double[] expected = new double[binCount];
-            expected[0] = binUpperBounds[0] == 0 ? (double) smallSampleSize / (double) n :
-                (double) ((binUpperBounds[0] + 1) * smallSampleSize) / (double) n;
-            for (int k = 1; k < binCount; k++) {
-                expected[k] = (double) smallSampleSize *
-                (double) (binUpperBounds[k] - binUpperBounds[k - 1]) / n;
-            }
-            for (int j = 0; j < numTests; j++) {
-                Arrays.fill(observed, 0);
-                for (int k = 0; k < smallSampleSize; k++) {
-                    final int value = generator.nextInt(n);
-                    Assert.assertTrue("nextInt range",(value >= 0) && (value < n));
-                    for (int l = 0; l < binCount; l++) {
-                        if (binUpperBounds[l] >= value) {
-                            observed[l]++;
-                            break;
-                        }
-                    }
-                }
-                if (testStatistic.chiSquareTest(expected, observed) < 0.01) {
-                    numFailures++;
-                }
-            }
-            if ((double) numFailures / (double) numTests > 0.02) {
-                Assert.fail("Too many failures for n = " + n +
-                " " + numFailures + " out of " + numTests + " tests failed.");
-            }
-        }
-    }
-
-    @Test
-    public void testNextLongDirect() {
-        long q1 = Long.MAX_VALUE/4;
-        long q2 = 2 *  q1;
-        long q3 = 3 * q1;
-
-        Frequency freq = new Frequency();
-        long val = 0;
-        int value = 0;
-        for (int i=0; i<smallSampleSize; i++) {
-            val = generator.nextLong();
-            val = val < 0 ? -val : val;
-            if (val < q1) {
-                value = 0;
-            } else if (val < q2) {
-                value = 1;
-            } else if (val < q3) {
-                value = 2;
-            } else {
-                value = 3;
-            }
-            freq.addValue(value);
-        }
-        long[] observed = new long[4];
-        for (int i=0; i<4; i++) {
-            observed[i] = freq.getCount(i);
-        }
-
-        /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
-         * Change to 11.34 for alpha = .01
-         */
-        Assert.assertTrue("chi-square test -- will fail about 1 in 1000 times",
-                testStatistic.chiSquare(expected,observed) < 16.27);
-    }
-
-    @Test
-    public void testNextBooleanDirect() {
-        long halfSampleSize = smallSampleSize / 2;
-        double[] expected = {halfSampleSize, halfSampleSize};
-        long[] observed = new long[2];
-        for (int i=0; i<smallSampleSize; i++) {
-            if (generator.nextBoolean()) {
-                observed[0]++;
-            } else {
-                observed[1]++;
-            }
-        }
-        /* Use ChiSquare dist with df = 2-1 = 1, alpha = .001
-         * Change to 6.635 for alpha = .01
-         */
-        Assert.assertTrue("chi-square test -- will fail about 1 in 1000 times",
-                testStatistic.chiSquare(expected,observed) < 10.828);
-    }
-
-    @Test
-    public void testNextFloatDirect() {
-        Frequency freq = new Frequency();
-        float val = 0;
-        int value = 0;
-        for (int i=0; i<smallSampleSize; i++) {
-            val = generator.nextFloat();
-            if (val < 0.25) {
-                value = 0;
-            } else if (val < 0.5) {
-                value = 1;
-            } else if (val < 0.75) {
-                value = 2;
-            } else {
-                value = 3;
-            }
-            freq.addValue(value);
-        }
-        long[] observed = new long[4];
-        for (int i=0; i<4; i++) {
-            observed[i] = freq.getCount(i);
-        }
-
-        /* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
-         * Change to 11.34 for alpha = .01
-         */
-        Assert.assertTrue("chi-square test -- will fail about 1 in 1000 times",
-                testStatistic.chiSquare(expected,observed) < 16.27);
-    }
-
-    @Test
-    public void testNextDouble() {
-        final double[] sample = new double[1000];
-        for (int i = 0; i < sample.length; i++) {
-            sample[i] = generator.nextDouble();
-        }
-        final RealDistribution uniformDistribution = new UniformRealDistribution(0,1);
-        final KolmogorovSmirnovTest ks = new KolmogorovSmirnovTest();
-        Assert.assertFalse(ks.kolmogorovSmirnovTest(uniformDistribution, sample, .01));
-    }
-
-
-    @Test(expected=MathIllegalArgumentException.class)
-    public void testNextIntPrecondition1() {
-        generator.nextInt(-1);
-    }
-
-    @Test(expected=MathIllegalArgumentException.class)
-    public void testNextIntPrecondition2() {
-        generator.nextInt(0);
-    }
-
-    @Test
-    public void testNextInt2() {
-        int walk = 0;
-        final int N = 10000;
-        for (int k = 0; k < N; ++k) {
-           if (generator.nextInt() >= 0) {
-               ++walk;
-           } else {
-               --walk;
-           }
-        }
-        Assert.assertTrue("Walked too far astray: " + walk + "\nNote: This " +
-                "test will fail randomly about 1 in 100 times.",
-                FastMath.abs(walk) < FastMath.sqrt(N) * 2.576);
-    }
-
-    @Test
-    public void testNextLong2() {
-        int walk = 0;
-        final int N = 1000;
-        for (int k = 0; k < N; ++k) {
-           if (generator.nextLong() >= 0) {
-               ++walk;
-           } else {
-               --walk;
-           }
-        }
-        Assert.assertTrue("Walked too far astray: " + walk + "\nNote: This " +
-                "test will fail randomly about 1 in 100 times.",
-                FastMath.abs(walk) < FastMath.sqrt(N) * 2.576);
-    }
-
-    @Test
-    public void testNextBoolean2() {
-        int walk = 0;
-        final int N = 10000;
-        for (int k = 0; k < N; ++k) {
-           if (generator.nextBoolean()) {
-               ++walk;
-           } else {
-               --walk;
-           }
-        }
-        Assert.assertTrue("Walked too far astray: " + walk + "\nNote: This " +
-                "test will fail randomly about 1 in 100 times.",
-                FastMath.abs(walk) < FastMath.sqrt(N) * 2.576);
-    }
-
-    @Test
-    public void testNextBytes() {
-        long[] count = new long[256];
-        byte[] bytes = new byte[10];
-        double[] expected = new double[256];
-        final int sampleSize = 100000;
-
-        for (int i = 0; i < 256; i++) {
-            expected[i] = (double) sampleSize / 265f;
-        }
-
-        for (int k = 0; k < sampleSize; ++k) {
-           generator.nextBytes(bytes);
-           for (byte b : bytes) {
-               ++count[b + 128];
-           }
-        }
-
-        TestUtils.assertChiSquareAccept(expected, count, 0.001);
-
-    }
-
-    // MATH-1300
-    @Test
-    public void testNextBytesChunks() {
-        final int[] chunkSizes = { 4, 8, 12, 16 };
-        final int[] chunks = { 1, 2, 3, 4, 5 };
-        for (int chunkSize : chunkSizes) {
-            for (int numChunks : chunks) {
-                checkNextBytesChunks(chunkSize, numChunks);
-            }
-        }
-    }
-
-    // MATH-1300: Test is ignored because it will fail due to the array
-    // size not being a multiple of 4.
-    @Ignore@Test
-    public void testNextBytesChunksFail() {
-        final int[] chunkSizes = { 5 };
-        final int[] chunks = { 4 };
-        for (int chunkSize : chunkSizes) {
-            for (int numChunks : chunks) {
-                checkNextBytesChunks(chunkSize, numChunks);
-            }
-        }
-    }
-
-    @Test
-    public void testSeeding() {
-        // makeGenerator initializes with fixed seed
-        RandomGenerator gen = makeGenerator();
-        RandomGenerator gen1 = makeGenerator();
-        checkSameSequence(gen, gen1);
-        // reseed, but recreate the second one
-        // verifies MATH-723
-        gen.setSeed(100);
-        gen1 = makeGenerator();
-        gen1.setSeed(100);
-        checkSameSequence(gen, gen1);
-    }
-
-    private void checkSameSequence(RandomGenerator gen1, RandomGenerator gen2) {
-        final int len = 11;  // Needs to be an odd number to check MATH-723
-        final double[][] values = new double[2][len];
-        for (int i = 0; i < len; i++) {
-            values[0][i] = gen1.nextDouble();
-        }
-        for (int i = 0; i < len; i++) {
-            values[1][i] = gen2.nextDouble();
-        }
-        Assert.assertTrue(Arrays.equals(values[0], values[1]));
-        for (int i = 0; i < len; i++) {
-            values[0][i] = gen1.nextFloat();
-        }
-        for (int i = 0; i < len; i++) {
-            values[1][i] = gen2.nextFloat();
-        }
-        Assert.assertTrue(Arrays.equals(values[0], values[1]));
-        for (int i = 0; i < len; i++) {
-            values[0][i] = gen1.nextInt();
-        }
-        for (int i = 0; i < len; i++) {
-            values[1][i] = gen2.nextInt();
-        }
-        Assert.assertTrue(Arrays.equals(values[0], values[1]));
-        for (int i = 0; i < len; i++) {
-            values[0][i] = gen1.nextLong();
-        }
-        for (int i = 0; i < len; i++) {
-            values[1][i] = gen2.nextLong();
-        }
-        Assert.assertTrue(Arrays.equals(values[0], values[1]));
-        for (int i = 0; i < len; i++) {
-            values[0][i] = gen1.nextInt(len);
-        }
-        for (int i = 0; i < len; i++) {
-            values[1][i] = gen2.nextInt(len);
-        }
-        Assert.assertTrue(Arrays.equals(values[0], values[1]));
-        for (int i = 0; i < len; i++) {
-            values[0][i] = gen1.nextBoolean() ? 1 : 0;
-        }
-        for (int i = 0; i < len; i++) {
-            values[1][i] = gen2.nextBoolean() ? 1 : 0;
-        }
-        Assert.assertTrue(Arrays.equals(values[0], values[1]));
-        for (int i = 0; i < len; i++) {
-            values[0][i] = gen1.nextGaussian();
-        }
-        for (int i = 0; i < len; i++) {
-            values[1][i] = gen2.nextGaussian();
-        }
-        Assert.assertTrue(Arrays.equals(values[0], values[1]));
-    }
-
-    // MATH-1300
-    private void checkNextBytesChunks(int chunkSize,
-                                      int numChunks) {
-        final RandomGenerator rg = makeGenerator();
-        final long seed = 1234567L;
-
-        final byte[] b1 = new byte[chunkSize * numChunks];
-        final byte[] b2 = new byte[chunkSize];
-
-        // Generate the chunks in a single call.
-        rg.setSeed(seed);
-        rg.nextBytes(b1);
-
-        // Reset.
-        rg.setSeed(seed);
-        // Generate the chunks in consecutive calls.
-        for (int i = 0; i < numChunks; i++) {
-            rg.nextBytes(b2);
-        }
-
-        // Store last 128 bytes chunk of b1 into b3.
-        final byte[] b3 = new byte[chunkSize];
-        System.arraycopy(b1, b1.length - b3.length, b3, 0, b3.length);
-
-        // Sequence of calls must be the same.
-        Assert.assertArrayEquals("chunkSize=" + chunkSize + " numChunks=" + numChunks,
-                                 b2, b3);
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/7550cb46/src/test/java/org/apache/commons/math4/random/RandomGeneratorFactoryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/RandomGeneratorFactoryTest.java b/src/test/java/org/apache/commons/math4/random/RandomGeneratorFactoryTest.java
deleted file mode 100644
index fc94e88..0000000
--- a/src/test/java/org/apache/commons/math4/random/RandomGeneratorFactoryTest.java
+++ /dev/null
@@ -1,36 +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.random.RandomGenerator;
-import org.apache.commons.math4.random.RandomGeneratorFactory;
-
-/**
- * Test cases for the {@link RandomGeneratorFactory} class.
- *
- */
-public class RandomGeneratorFactoryTest extends RandomGeneratorAbstractTest {
-
-    @Override
-    protected RandomGenerator makeGenerator() {
-        RandomGenerator generator = RandomGeneratorFactory.createRandomGenerator(new Random());
-        generator.setSeed(1001);
-        return generator;
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/7550cb46/src/test/java/org/apache/commons/math4/random/Well19937cTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/Well19937cTest.java b/src/test/java/org/apache/commons/math4/random/Well19937cTest.java
deleted file mode 100644
index cfffcd1..0000000
--- a/src/test/java/org/apache/commons/math4/random/Well19937cTest.java
+++ /dev/null
@@ -1,117 +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 org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class Well19937cTest extends RandomGeneratorAbstractTest {
-
-    @Override
-    public RandomGenerator makeGenerator() {
-        return new Well19937c(100);
-    }
-
-    @Test
-    public void testReferenceCode() {
-        int[] base = {
-              740849862,  1202665156,  -199039369,  -259008301,  -291878969, -1164428990, -1565918811,   491009864,
-            -1883086670,  1383450241,  1244617256,   689006653, -1576746370, -1307940314,  1421489086,  1742094000,
-             -595495729,  1047766204,  1875773301, -1637793284,  1379017098,   262792705,   191880010,  -251000180,
-            -1753047622,  -972355720,    90626881,  1644693418,  1503365577,   439653419,  1806361562,  1268823869
-         };
-        int[] init = new int[624];
-        for (int i = 0; i < init.length; ++i) {
-            init[i] = base[i % base.length] + i;
-        }
-        Well19937c mt = new Well19937c(init);
-        int[] refInt = {
-            2128528153,    327121884,    935445371,    -83026433,  -1041143083,   2084595880,  -1073535198,  -1678863790,   -523636021,  -1514837782,   -736786810,   1527711112,  -1051227939,    978703380,    410322163,   1727815703,
-            -648426354,    636056441,   1954420292,     17754810,   -958628705,  -1091307602,   1793078738,  -1680336346,   1792171272,    941973796,  -2066152330,  -1248758068,  -1061211586,    262020189,   1276960217,   -233886784,
-            1767509252,  -1811939255,   -406116097,   -742435920,  -1349799525,    240329556,   -332161345,   1488943143,   -332244280,   2093328957,    674753300,  -1930135556,    257111467,     63793650,  -1964335223,   1315849133,
-            -797349146,   1372022250,  -1451892049,  -1325138957,   -870401239,  -1294317369,     91490879,    386205044,   -704074702,  -1230679067,   1513674392,   -262996240,   1196007314,   1398903796,    803719762,  -1750926831,
-           -1268814180,   1233515404,   1498313934,   -970591257,    611113671,   -261632474,   1834097325,   1709440492,   -150396854,   2120561003,    -62645660,    479080234,   1535125050,   1823378695,  -1129289329,  -1095198399,
-            2092564733,     78836308,   -692015409,   1647147229,  -1847922219,   1838279320,   -848333841,  -1375151778,    920238861,   1512628290,   -749439404,    288851918,   -427218675,    679640964,    425700808,  -2077624511,
-           -1929434455,   -647176419,    650437190,  -1926749131,  -1564744729,    734494454,    108193743,    246246679,    810042628,   1952337771,   1089253730,  -1874275331,   1428419392,   -492969232,   1945270770,   -201265602,
-            -755490251,   -624426214,   -699605715,   -113446478,    809091299,  -1521531511,   1136505389,   -523660964,    132928433,   1926559713,  -1485314325,   -508322506,     46307756,  -1627479740,   -589386406,  -1855555892,
-             584299545,   1272841066,   -597242658,    925134545,   1102566453,   -753335037,     -9523218,  -1778632375,    568963646,    764338254,   1259944540,  -2000124642,   1307414525,   -151384482,    807294400,   1993749511,
-             -15503094,   -709471492,   2104830082,   1387684315,  -1929056119,    224254668,   -733550950,   -889466978,  -1987783335,   -437144026,    995905753,  -1021386158,  -1096313388,  -1014152835,  -1303258241,   1201884788,
-           -1845042397,   1421462511,    980805867,   2143771251,    481226968,   1790544569,    328448328,   1995857639,    -66668269,  -1411421267,   -222586606,    866950765,   -308713926,  -1048350893,    993222402,  -1139265642,
-            -871837948,   1145571913,    381928580,     35386691,   1640961123,  -1192981020,    775971009,    594246635,   1603197812,   -575106766,   2023682000,  -1636301903,   -718093720,  -1666421635,  -2146115988,    320593570,
-             287355418,    454400027,   1112753817,   1751196267,    782077910,  -1478447368,  -1007557264,   -862315517,  -2035355952,   2123515250,   -557641502,  -1789932035,    879640129,     44167603,    791148984,   1382939723,
-           -2135684233,   1825489580,    937345485,  -1839983359,  -1536880111,  -1472578359,   1548052748,  -1471535862,    -14508727,   1509621398,  -2134967452,   -787485401,    815341660,   -327905128,   1028096737,    866906991,
-           -1585990806,    859229080,    234806270,    998518056,  -1897890815,   -900923587,   1179856752,   1529572451,    620486106,   1119836556,   1661285564,   2097404633,  -1437490790,    265306115,   -984880135,   1326751968,
-            1280043536,    680210701,    155786166,   1550973250,   -325781949,   -597789777,     -1939780,   1345275487,   1930450001,    941449704,    669301309,    693651713,   -990721514,    582968326,    976132553,  -1892942099,
-           -1065070157,   -711990993,   -688974833,  -1026091683,   1115346827,  -1305730749,  -1733626381,   -364566696,    -21761572,    -37152746,   -262011730,   1302722752,  -1806313409,   -767072509,    764112137,   1671157377,
-            1837645038,  -1021606421,  -1781898911,   -232127459,   -310742675,  -1818095744,  -1128320656,   -705565953,   -354445532,   -523172807,   -433877202,    131904485,    -64292316,    381829280,    229820263,   1797992622,
-            1359665678,    978481451,   -885267130,  -1415988446,   -356533788,   -961419072,   1938703090,    708344111,    679299953,    744615129,   1328811158,   1257588574,    569216282,   -753296151,  -1519838713,   2016884452,
-            1062684606,   1561736790,   2028643511,  -1353001615,    886376832,   1466953172,   1664783899,   1290079981,    -57483993,  -1176112430,   1634916316,   1976304475,   1374136869,   -648738039,   1058175869,   -909000745,
-           -1526439218,    726626991,   2066596202,     64980943,    -26166577,   -885900005,  -1821546816,  -1103727665,    730606315,  -1324948459,   -696956940,  -1300869403,   1171578314,    797249074,  -1600611618,   1928247682,
-             307164165,  -1482476232,  -1886179640,   1306433392,   1945271359,  -1272113751,  -1285984081,  -2057145549,    795047465,   1262569087,  -1239828121,   1426641636,   -786371495,   2120199316,   1273690652,     74457589,
-           -1033394229,    338952565,     46122958,   1225741533,   2115308090,    678200841,  -1618264885,   -101162569,  -1628976330,  -1232839500,    468709044,   1876019116,     92723122,    233398255,   -554960844,     38494196,
-            -406437278,   2083528643,  -1106878615,   -340722557,  -2123964932,    223183343,    108918116,  -1014629054,   -901344544,   -838896840,  -1908460517,  -1763508731,   -926890833,   1703791049,   -667755577,   1694418389,
-             791641263,   1095689677,   1119202039,  -1419111438,  -2012259010,    188017439,  -1775110395,  -1971099661,  -1688113734,    131472813,   -776304959,   1511388884,   2080864872,  -1733824651,   1992147495,   1119828320,
-            1065336924,  -1357606762,    462963503,   1180719494,   -202678962,   -892646595,    605869323,   1144255663,    878462678,  -1051371303,    872374876,    631322271,   -172600544,  -1552071375,  -1939570033,    151973117,
-            1640861022,    310682640,     34192866,   2057773671,  -2004476027,  -1879238973,    582736114,    900581664,   -427390545,  -1232348528,   -535115984,   1321853054,     69386780,  -1729375922,   1418473715,   1022091451,
-             496799289,    -80757405,  -1903543310,  -1128846846,      1703964,   1984450945,    856753858,   -812919184,    775486323,  -1376056193,    638628840,    314243536,   1030626207,    644050997,     73923896,    362270613,
-             236584904,   1463240891,   -223614432,    435371594,   -751940030,   -124274553,  -1991092884,   1579624267,   1249632649,    157589625,   -345229739,   -366245207,  -1399995986,   1651729983,   1965074340,  -1108970305,
-            1163690769,   1732013523,  -1461252895,    669755552,   -476503675,   -264578685,    -32813949,    288222188,    -25734262,    106040916,   1654395626,   -365148479,   2014455846,  -2040447994,   1351639280,   -919975757,
-           -1970412139,    -47306532,    222377665,   -363434917,  -1091717516,   2090685531,  -1221091649,  -1729649190,  -1239406708,   1064945398,   -105437479,   -419675255,     74701669,    -12862899,   -498269844,   1566898997,
-           -1872838355,   1596887574,    485902962,    469225597,   -881763553,   1307841032,  -1642872487,   1388543045,    379792876,   1095683384,    840780732,   1934378038,   1851278350,  -1359389423,    130868458,   -313448799,
-            -663624816,   1031714153,   -608443411,   -205137499,  -1849464427,   1973593637,   1068741808,  -1420655961,   1188762305,    954044841,   -995454462,  -1818101092,  -1937201943,   -324541290,  -1520603933,    572873173,
-            -554764496,   1051557081,  -1245136076,   -985349536,    329320398,   1787901464,    -37803304,  -1759310177,  -1463492617,  -1861729663,   1251768782,    256937091,   -779036948,  -2049893864,   1256022877,   1228075657,
-           -1550195255,   -611319853,   1190797155,   2047604112,   -576077160,  -1532843331,  -1324899394,   -159729560,   -622525946,  -1080302767,   -236033484,   1895243903,   -410123689,  -1944154157,   -681781021,   1208453003,
-             579595878,   1303914051,   -145607082,   -131567277,  -1917288455,    894217359,   -175688726,  -1585480723,    663691440,  -1140068263,   -641711178,   1596080008,    629197693,    976422358,  -1570451095,    525923776,
-             895046136,   -504151767,   1602553020,  -1233054923,  -1798474837,  -1488857895,   1055782627,    261863143,   1879276655,    488240679,   1910982611,  -1919441259,    370435945,   1265230086,  -1293284428,  -1503576227,
-            2076963035,  -1379628250,   1157098875,   1984461153,  -1947837397,   1705880124,   1453607404,  -1233649748,   1479943773,   -863878721,   -862415630,   -736723275,    940306358,  -1596000684,  -1174889953,   -615723892,
-            -885006597,  -1796723178,   1844159055,   -188942309,   2107251811,  -1675486996,  -1009475178,   -859263556,   -431866963,     -9593673,  -1878920923,   -104853791,  -1535224994,    -69315537,    586690130,  -1292234796,
-            1378749456,   -301873019,   -319297563,   1677205851,    292450579,  -1289441171,   1788113680,   1907606333,   1464711611,  -1372023606,  -1978832445,  -1772259768,   1949124464,   1818322887,  -1138036603,   1249727628,
-           -1474866449,  -1868013169,  -1384567593,    717007936,    954189997,  -1900561040,    738470389,   -158973180,   1732860784,   1936031206,  -1133354740,  -1173166665,   1432976712,    852636081,   1732064691,  -1831788120,
-            1273933579,    455403217,   1988395890,    106493468,    506092152,   -610530423,   1698053512,   1311747476,   1969503012,  -1887461759,   1613543073,    903200334,   -737865837,    325656800,  -1234001200,   1492148864,
-            2009861533,   -368262605,   1091338541,   2076108119,   -961392337,   1835877112,    316250307,   -853333391,  -2125443777,    815363504,   -798707803,   -158146540,    690786114,   -530775684,   1203556940,   1611485582,
-           -1661412270,    -53184506,   2126287444,   -232222229,   1559486057,    283532250,   1202760418,    932144172,   1082594656,   -570104011,    413509167,   -995027177,   -996477516,      -540544,   -745537167,   -712135469,
-            -996294983,   -592787198,   1889840948,   1314628747,   -394266926,   -682316577,    456447239,   1728806063,   -396279614,    -43387643,   1915717013,   -861574144,  -1078710588,   -561401249,   1111464540,     63643984,
-           -1693870413,   -968369980,  -1053148188,    708799038,   1883537988,    373371671,   -156410415,  -1596483236,  -1846890431,    888692915,  -1025632583,  -1666477591,   -343066267,  -2059058792,    641501628,  -1744347292,
-            1648632991,   1743540146,   2020952406,    164014499,    990508262,   1706408228,  -1236471842,   -347116260,   1843634523,    827255665,    300519853,  -1265974830,   -547247177,   -583064554,  -1995437077,    689210107,
-             -93151393,    835365056,   1706367315,  -1605902756,    200954895,    431093688,   -277573364,   -928486713,   -552221973,    145432789,   1128919795,   1675095586,   1930359882,   1215849501,  -1447770583,    657776490,
-            1885869860,  -1629237204,   -868897479,  -1258169760,   1828140195,   -883850439,    463933909,   -347361158,   1478116648,    801176896,  -1501915899,   1017335748,  -1654508882,    123994786,   1588785290,    791166651,
-           -1523108535,    340411166,   -496474762,  -1189711141,     -7392628,   2045171250,  -1245366209,    834787230,  -1346883181,   2034209454,    737043362,    898803323,   1983089087,  -1845404320,      9585188,  -1180608323,
-            1665100606,   1949474222,   -211115008,   1151308295,  -2132174259,    913126312,  -2085061672,   1419864120,  -1134542954,    -53833957,   -246913211,    468382370,  -1759479323,   1136686211,   1307012488,  -2036299559,
-           -1346099736,    314743106,  -1683101865,   -947151948,   -234529696,  -2103334293,   -279256894,     -1484257,  -1053953017,   1801205399,    941594454,   -874119215,   -672865187,    762284205,  -1494975451,    486607927,
-            -898264389,  -1711861093,   -212572760,   2106484281,  -1610786470,   1352525590,   -837779586,   1568282001,   -593019125,  -1146260782,  -1595879979,   -640781858,   1107692311,   1547132709,  -1928385535,  -2057772805,
-             634887038,    329772618,    942136006,   -864405576,    501883884,   1537141484,  -1180626836,   1123055420,   1090885851,    421662750,   2033111605,   1710917425,  -1118058244,     74321279,    257328195,  -1199940697,
-             208625996,   -442341447,    808119183,   1166827075,   1177417517,  -1856155370,  -1464837036,    -60624923,  -1306220638,    -91104698,  -1434621430,    548899241,     37351476,   1478278431,  -1255061434,    248470035,
-            -104642597,  -1865169521,   1418373655,  -1660810523,  -2129015436,    154612798,    276575732,   1930338442,    179503250,   -929294855,    -39452027,  -1377657544,   1442322193,   1137511318,   -432158653,   -984801987,
-             743099148,  -1118893528,   -904123623,  -1273146363,  -1884800406,   -803169061,   1254123158,   -484252077,    317646844,    404246525,  -1230293916,   1121445742,    -19657507,    652967153,  -1055406692,   -468950719,
-           -1493532921,  -1447624258,  -1369679689,  -1517000228,   -145853307,   1518006526,   1591195514,  -1475557146,   -909722097,   2103182976,   -406830579,  -2124025254,  -1804819507,  -1357512858,    567321869,    409048156,
-             567805180,   1749009386,   1762759722,  -1770324077,   1271140844,    468219092,    955792405,   1911965665,   1876314424,   -718200715,  -1278883927,   1392281730,   -120519585,    851473793,    245054754,    -33369039,
-            -284877584,   -479534880,   -212346563,   -122017521,  -1461429983,   1331007370,   1788621721,   1739036536,   1446350953,  -1985448033,    685528610,  -1386434659,   1368233993,   2021786790,   1596478397,  -1716635278,
-           -2011083017,    171876097,   -311529197,    687812052,    377000657,  -1055547517,  -1499047842,  -1818434951,   -120863666,     33888043,  -1387509273,   -541540700,   1162597745,  -1331415338,   1931708792,   -850270000,
-             663845594,   1536495943,   -322924971,  -1380272203,    261190298,   -204874428,  -2104974031,    883819928,    155808204,  -1454446035,   1323388464,  -1696505728,   1549800285,   1018150463,  -1327715703,  -1582480640,
-            1013659809,  -1820360082,   1666498787,   1406120540,   -196541482,   1248470531,  -1250433281,    836375878,    177646854,  -1927020253,   2145878321,    689712096,   -596605921,    348283199,   1916993096,    481356808,
-            -339687826,   1219340319,    718895887,  -2007521340,  -1859185806,   2042164737,    -58146784,    742449142,   1930754708,    780832111,    715056441,  -1393886151,     -8150527,   -599607443,   -537300865,  -1212516084
-        };
-
-        for (int i = 0; i < refInt.length; ++i) {
-            Assert.assertEquals(refInt[i], mt.nextInt());
-        }
-
-    }
-
-}


[3/5] [math] MATH-1366

Posted by er...@apache.org.
MATH-1366

Deleted a bunch of inter-dependent classes and unit tests.

All RNG algorithms previously implemented in package "o.a.c.m.random" are now in package "o.a.c.m.rng.internal.source32".
Functionalities of "RandomDataGenerator" are provided by "RandomUtils.DataGenerator" and classes in package "o.a.c.m.distribution".
Base classes "BitsStreamGenerator" and "AbstractWell" are obsolete (replaced by classes in package "o.a.c.m.rng.internal" and below).


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

Branch: refs/heads/task-MATH-1366
Commit: 7550cb46417b396fed21f2ec149b465e7d039cef
Parents: 4bbe9ee
Author: Gilles <er...@apache.org>
Authored: Fri May 20 14:07:46 2016 +0200
Committer: Gilles <er...@apache.org>
Committed: Fri May 20 14:07:46 2016 +0200

----------------------------------------------------------------------
 .../commons/math4/random/AbstractWell.java      |  246 ----
 .../math4/random/BitsStreamGenerator.java       |  218 ----
 .../math4/random/RandomDataGenerator.java       | 1005 ---------------
 .../apache/commons/math4/random/Well19937c.java |  115 --
 .../math4/random/BitsStreamGeneratorTest.java   |   86 --
 .../math4/random/RandomDataGeneratorTest.java   | 1212 ------------------
 .../random/RandomGeneratorAbstractTest.java     |  462 -------
 .../random/RandomGeneratorFactoryTest.java      |   36 -
 .../commons/math4/random/Well19937cTest.java    |  117 --
 9 files changed, 3497 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/7550cb46/src/main/java/org/apache/commons/math4/random/AbstractWell.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/AbstractWell.java b/src/main/java/org/apache/commons/math4/random/AbstractWell.java
deleted file mode 100644
index 7251bcd..0000000
--- a/src/main/java/org/apache/commons/math4/random/AbstractWell.java
+++ /dev/null
@@ -1,246 +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.io.Serializable;
-
-import org.apache.commons.math4.util.FastMath;
-
-
-/** This abstract class implements the WELL class of pseudo-random number generator
- * from Fran&ccedil;ois Panneton, Pierre L'Ecuyer and Makoto Matsumoto.
- * <p>
- * This generator is described in a paper by Fran&ccedil;ois Panneton,
- * Pierre L'Ecuyer and Makoto Matsumoto <a
- * href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf">Improved
- * Long-Period Generators Based on Linear Recurrences Modulo 2</a> ACM
- * Transactions on Mathematical Software, 32, 1 (2006). The errata for the paper
- * are in <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng-errata.txt">wellrng-errata.txt</a>.</p>
- *
- * @see <a href="http://www.iro.umontreal.ca/~panneton/WELLRNG.html">WELL Random number generator</a>
- * @since 2.2
- */
-public abstract class AbstractWell extends BitsStreamGenerator implements Serializable {
-
-    /** Serializable version identifier. */
-    private static final long serialVersionUID = 20150223L;
-
-    /** Current index in the bytes pool. */
-    protected int index;
-
-    /** Bytes pool. */
-    protected final int[] v;
-
-    /** Creates a new random number generator.
-     * <p>The instance is initialized using the current time plus the
-     * system identity hash code of this instance as the seed.</p>
-     * @param k number of bits in the pool (not necessarily a multiple of 32)
-     */
-    protected AbstractWell(final int k) {
-        this(k, null);
-    }
-
-    /** Creates a new random number generator using a single int seed.
-     * @param k number of bits in the pool (not necessarily a multiple of 32)
-     * @param seed the initial seed (32 bits integer)
-     */
-    protected AbstractWell(final int k, final int seed) {
-        this(k, new int[] { seed });
-    }
-
-    /** Creates a new random number generator using an int array seed.
-     * @param k number of bits in the pool (not necessarily a multiple of 32)
-     * @param seed the initial seed (32 bits integers array), if null
-     * the seed of the generator will be related to the current time
-     */
-    protected AbstractWell(final int k, final int[] seed) {
-
-        final int r = calculateBlockCount(k);
-        this.v      = new int[r];
-        this.index  = 0;
-
-        // initialize the pool content
-        setSeed(seed);
-
-    }
-
-    /** Creates a new random number generator using a single long seed.
-     * @param k number of bits in the pool (not necessarily a multiple of 32)
-     * @param seed the initial seed (64 bits integer)
-     */
-    protected AbstractWell(final int k, final long seed) {
-        this(k, new int[] { (int) (seed >>> 32), (int) (seed & 0xffffffffl) });
-    }
-
-    /** Reinitialize the generator as if just built with the given int seed.
-     * <p>The state of the generator is exactly the same as a new
-     * generator built with the same seed.</p>
-     * @param seed the initial seed (32 bits integer)
-     */
-    @Override
-    public void setSeed(final int seed) {
-        setSeed(new int[] { seed });
-    }
-
-    /** Reinitialize the generator as if just built with the given int array seed.
-     * <p>The state of the generator is exactly the same as a new
-     * generator built with the same seed.</p>
-     * @param seed the initial seed (32 bits integers array). If null
-     * the seed of the generator will be the system time plus the system identity
-     * hash code of the instance.
-     */
-    @Override
-    public void setSeed(final int[] seed) {
-        if (seed == null) {
-            setSeed(System.currentTimeMillis() + System.identityHashCode(this));
-            return;
-        }
-
-        System.arraycopy(seed, 0, v, 0, FastMath.min(seed.length, v.length));
-
-        if (seed.length < v.length) {
-            for (int i = seed.length; i < v.length; ++i) {
-                final long l = v[i - seed.length];
-                v[i] = (int) ((1812433253l * (l ^ (l >> 30)) + i) & 0xffffffffL);
-            }
-        }
-
-        index = 0;
-        clear();  // Clear normal deviate cache
-    }
-
-    /** Reinitialize the generator as if just built with the given long seed.
-     * <p>The state of the generator is exactly the same as a new
-     * generator built with the same seed.</p>
-     * @param seed the initial seed (64 bits integer)
-     */
-    @Override
-    public void setSeed(final long seed) {
-        setSeed(new int[] { (int) (seed >>> 32), (int) (seed & 0xffffffffl) });
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected abstract int next(final int bits);
-
-    /** Calculate the number of 32-bits blocks.
-     * @param k number of bits in the pool (not necessarily a multiple of 32)
-     * @return the number of 32-bits blocks
-     */
-    private static int calculateBlockCount(final int k) {
-        // the bits pool contains k bits, k = r w - p where r is the number
-        // of w bits blocks, w is the block size (always 32 in the original paper)
-        // and p is the number of unused bits in the last block
-        final int w = 32;
-        final int r = (k + w - 1) / w;
-        return r;
-    }
-
-    /**
-     * Inner class used to store the indirection index table which is fixed for a given type of WELL class
-     * of pseudo-random number generator.
-     *
-     * @since 4.0
-     */
-    protected static final class IndexTable {
-        /** Index indirection table giving for each index its predecessor taking table size into account. */
-        private final int[] iRm1;
-
-        /** Index indirection table giving for each index its second predecessor taking table size into account. */
-        private final int[] iRm2;
-
-        /** Index indirection table giving for each index the value index + m1 taking table size into account. */
-        private final int[] i1;
-
-        /** Index indirection table giving for each index the value index + m2 taking table size into account. */
-        private final int[] i2;
-
-        /** Index indirection table giving for each index the value index + m3 taking table size into account. */
-        private final int[] i3;
-
-        /** Creates a new pre-calculated indirection index table.
-         * @param k number of bits in the pool (not necessarily a multiple of 32)
-         * @param m1 first parameter of the algorithm
-         * @param m2 second parameter of the algorithm
-         * @param m3 third parameter of the algorithm
-         */
-        public IndexTable(final int k, final int m1, final int m2, final int m3) {
-
-            final int r = calculateBlockCount(k);
-
-            // precompute indirection index tables. These tables are used for optimizing access
-            // they allow saving computations like "(j + r - 2) % r" with costly modulo operations
-            iRm1 = new int[r];
-            iRm2 = new int[r];
-            i1   = new int[r];
-            i2   = new int[r];
-            i3   = new int[r];
-            for (int j = 0; j < r; ++j) {
-                iRm1[j] = (j + r - 1) % r;
-                iRm2[j] = (j + r - 2) % r;
-                i1[j]   = (j + m1)    % r;
-                i2[j]   = (j + m2)    % r;
-                i3[j]   = (j + m3)    % r;
-            }
-        }
-
-        /**
-         * Returns the predecessor of the given index modulo the table size.
-         * @param index the index to look at
-         * @return (index - 1) % table size
-         */
-        public int getIndexPred(final int index) {
-            return iRm1[index];
-        }
-
-        /**
-         * Returns the second predecessor of the given index modulo the table size.
-         * @param index the index to look at
-         * @return (index - 2) % table size
-         */
-        public int getIndexPred2(final int index) {
-            return iRm2[index];
-        }
-
-        /**
-         * Returns index + M1 modulo the table size.
-         * @param index the index to look at
-         * @return (index + M1) % table size
-         */
-        public int getIndexM1(final int index) {
-            return i1[index];
-        }
-
-        /**
-         * Returns index + M2 modulo the table size.
-         * @param index the index to look at
-         * @return (index + M2) % table size
-         */
-        public int getIndexM2(final int index) {
-            return i2[index];
-        }
-
-        /**
-         * Returns index + M3 modulo the table size.
-         * @param index the index to look at
-         * @return (index + M3) % table size
-         */
-        public int getIndexM3(final int index) {
-            return i3[index];
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/7550cb46/src/main/java/org/apache/commons/math4/random/BitsStreamGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/BitsStreamGenerator.java b/src/main/java/org/apache/commons/math4/random/BitsStreamGenerator.java
deleted file mode 100644
index 4cf6823..0000000
--- a/src/main/java/org/apache/commons/math4/random/BitsStreamGenerator.java
+++ /dev/null
@@ -1,218 +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.io.Serializable;
-
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
-import org.apache.commons.math4.util.FastMath;
-
-/** Base class for random number generators that generates bits streams.
- *
- * @since 2.0
- */
-public abstract class BitsStreamGenerator
-    implements RandomGenerator,
-               Serializable {
-    /** Serializable version identifier */
-    private static final long serialVersionUID = 20130104L;
-    /** Next gaussian. */
-    private double nextGaussian;
-
-    /**
-     * Creates a new random number generator.
-     */
-    public BitsStreamGenerator() {
-        nextGaussian = Double.NaN;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public abstract void setSeed(int seed);
-
-    /** {@inheritDoc} */
-    @Override
-    public abstract void setSeed(int[] seed);
-
-    /** {@inheritDoc} */
-    @Override
-    public abstract void setSeed(long seed);
-
-    /** Generate next pseudorandom number.
-     * <p>This method is the core generation algorithm. It is used by all the
-     * public generation methods for the various primitive types {@link
-     * #nextBoolean()}, {@link #nextBytes(byte[])}, {@link #nextDouble()},
-     * {@link #nextFloat()}, {@link #nextGaussian()}, {@link #nextInt()},
-     * {@link #next(int)} and {@link #nextLong()}.</p>
-     * @param bits number of random bits to produce
-     * @return random bits generated
-     */
-    protected abstract int next(int bits);
-
-    /** {@inheritDoc} */
-    @Override
-    public boolean nextBoolean() {
-        return next(1) != 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void nextBytes(byte[] bytes) {
-        // Multiple 4 part of length (i.e. length with two least significant bits unset).
-        final int max = bytes.length & 0x7ffffffc;
-
-        int index = 0;
-        // Start filling in the byte array, 4 bytes at a time.
-        while (index < max) {
-            final int random = next(32);
-            bytes[index++] = (byte) random;
-            bytes[index++] = (byte) (random >>> 8);
-            bytes[index++] = (byte) (random >>> 16);
-            bytes[index++] = (byte) (random >>> 24);
-        }
-
-        // Fill in the remaing bytes.
-        if (index < bytes.length) {
-            int random = next(32);
-            while (true) {
-                bytes[index++] = (byte) random;
-                if (index < bytes.length) {
-                    random >>>= 8;
-                } else {
-                    break;
-                }
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public double nextDouble() {
-        final long high = ((long) next(26)) << 26;
-        final int  low  = next(26);
-        return (high | low) * 0x1.0p-52d;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public float nextFloat() {
-        return next(23) * 0x1.0p-23f;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public double nextGaussian() {
-
-        final double random;
-        if (Double.isNaN(nextGaussian)) {
-            // generate a new pair of gaussian numbers
-            final double x = nextDouble();
-            final double y = nextDouble();
-            final double alpha = 2 * FastMath.PI * x;
-            final double r      = FastMath.sqrt(-2 * FastMath.log(y));
-            random       = r * FastMath.cos(alpha);
-            nextGaussian = r * FastMath.sin(alpha);
-        } else {
-            // use the second element of the pair already generated
-            random = nextGaussian;
-            nextGaussian = Double.NaN;
-        }
-
-        return random;
-
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public int nextInt() {
-        return next(32);
-    }
-
-    /**
-     * {@inheritDoc}
-     * <p>This default implementation is copied from Apache Harmony
-     * java.util.Random (r929253).</p>
-     *
-     * <p>Implementation notes: <ul>
-     * <li>If n is a power of 2, this method returns
-     * {@code (int) ((n * (long) next(31)) >> 31)}.</li>
-     *
-     * <li>If n is not a power of 2, what is returned is {@code next(31) % n}
-     * with {@code next(31)} values rejected (i.e. regenerated) until a
-     * value that is larger than the remainder of {@code Integer.MAX_VALUE / n}
-     * is generated. Rejection of this initial segment is necessary to ensure
-     * a uniform distribution.</li></ul></p>
-     */
-    @Override
-    public int nextInt(int n) throws IllegalArgumentException {
-        if (n > 0) {
-            if ((n & -n) == n) {
-                return (int) ((n * (long) next(31)) >> 31);
-            }
-            int bits;
-            int val;
-            do {
-                bits = next(31);
-                val = bits % n;
-            } while (bits - val + (n - 1) < 0);
-            return val;
-        }
-        throw new NotStrictlyPositiveException(n);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public long nextLong() {
-        final long high  = ((long) next(32)) << 32;
-        final long  low  = (next(32)) & 0xffffffffL;
-        return high | low;
-    }
-
-    /**
-     * Returns a pseudorandom, uniformly distributed {@code long} value
-     * between 0 (inclusive) and the specified value (exclusive), drawn from
-     * this random number generator's sequence.
-     *
-     * @param n the bound on the random number to be returned.  Must be
-     * positive.
-     * @return  a pseudorandom, uniformly distributed {@code long}
-     * value between 0 (inclusive) and n (exclusive).
-     * @throws IllegalArgumentException  if n is not positive.
-     */
-    public long nextLong(long n) throws IllegalArgumentException {
-        if (n > 0) {
-            long bits;
-            long val;
-            do {
-                bits = ((long) next(31)) << 32;
-                bits |= ((long) next(32)) & 0xffffffffL;
-                val  = bits % n;
-            } while (bits - val + (n - 1) < 0);
-            return val;
-        }
-        throw new NotStrictlyPositiveException(n);
-    }
-
-    /**
-     * Clears the cache used by the default implementation of
-     * {@link #nextGaussian}.
-     */
-    public void clear() {
-        nextGaussian = Double.NaN;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/7550cb46/src/main/java/org/apache/commons/math4/random/RandomDataGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/RandomDataGenerator.java b/src/main/java/org/apache/commons/math4/random/RandomDataGenerator.java
deleted file mode 100644
index e19b136..0000000
--- a/src/main/java/org/apache/commons/math4/random/RandomDataGenerator.java
+++ /dev/null
@@ -1,1005 +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.io.Serializable;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.SecureRandom;
-import java.util.Collection;
-
-import org.apache.commons.math4.distribution.BetaDistribution;
-import org.apache.commons.math4.distribution.BinomialDistribution;
-import org.apache.commons.math4.distribution.CauchyDistribution;
-import org.apache.commons.math4.distribution.ChiSquaredDistribution;
-import org.apache.commons.math4.distribution.ExponentialDistribution;
-import org.apache.commons.math4.distribution.FDistribution;
-import org.apache.commons.math4.distribution.GammaDistribution;
-import org.apache.commons.math4.distribution.HypergeometricDistribution;
-import org.apache.commons.math4.distribution.PascalDistribution;
-import org.apache.commons.math4.distribution.PoissonDistribution;
-import org.apache.commons.math4.distribution.TDistribution;
-import org.apache.commons.math4.distribution.UniformIntegerDistribution;
-import org.apache.commons.math4.distribution.WeibullDistribution;
-import org.apache.commons.math4.distribution.ZipfDistribution;
-import org.apache.commons.math4.exception.MathInternalError;
-import org.apache.commons.math4.exception.NotANumberException;
-import org.apache.commons.math4.exception.NotFiniteNumberException;
-import org.apache.commons.math4.exception.NotPositiveException;
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
-import org.apache.commons.math4.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.exception.OutOfRangeException;
-import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.rng.UniformRandomProvider;
-import org.apache.commons.math4.util.MathArrays;
-
-/**
- * Generates random deviates and other random data using a {@link RandomGenerator}
- * instance to generate non-secure data and a {@link java.security.SecureRandom}
- * instance to provide data for the <code>nextSecureXxx</code> methods. If no
- * <code>RandomGenerator</code> is provided in the constructor, the default is
- * to use a {@link Well19937c} generator. To plug in a different
- * implementation, either implement <code>RandomGenerator</code> directly or
- * extend {@link AbstractRandomGenerator}.
- * <p>
- * Supports reseeding the underlying pseudo-random number generator (PRNG). The
- * <code>SecurityProvider</code> and <code>Algorithm</code> used by the
- * <code>SecureRandom</code> instance can also be reset.
- * </p>
- * <p>
- * For details on the default PRNGs, see {@link java.util.Random} and
- * {@link java.security.SecureRandom}.
- * </p>
- * <p>
- * <strong>Usage Notes</strong>:
- * <ul>
- * <li>
- * Instance variables are used to maintain <code>RandomGenerator</code> and
- * <code>SecureRandom</code> instances used in data generation. Therefore, to
- * generate a random sequence of values or strings, you should use just
- * <strong>one</strong> <code>RandomDataGenerator</code> instance repeatedly.</li>
- * <li>
- * The "secure" methods are *much* slower. These should be used only when a
- * cryptographically secure random sequence is required. A secure random
- * sequence is a sequence of pseudo-random values which, in addition to being
- * well-dispersed (so no subsequence of values is an any more likely than other
- * subsequence of the the same length), also has the additional property that
- * knowledge of values generated up to any point in the sequence does not make
- * it any easier to predict subsequent values.</li>
- * <li>
- * When a new <code>RandomDataGenerator</code> is created, the underlying random
- * number generators are <strong>not</strong> initialized. If you do not
- * explicitly seed the default non-secure generator, it is seeded with the
- * current time in milliseconds plus the system identity hash code on first use.
- * The same holds for the secure generator. If you provide a <code>RandomGenerator</code>
- * to the constructor, however, this generator is not reseeded by the constructor
- * nor is it reseeded on first use.</li>
- * <li>
- * The <code>reSeed</code> and <code>reSeedSecure</code> methods delegate to the
- * corresponding methods on the underlying <code>RandomGenerator</code> and
- * <code>SecureRandom</code> instances. Therefore, <code>reSeed(long)</code>
- * fully resets the initial state of the non-secure random number generator (so
- * that reseeding with a specific value always results in the same subsequent
- * random sequence); whereas reSeedSecure(long) does <strong>not</strong>
- * reinitialize the secure random number generator (so secure sequences started
- * with calls to reseedSecure(long) won't be identical).</li>
- * <li>
- * This implementation is not synchronized. The underlying <code>RandomGenerator</code>
- * or <code>SecureRandom</code> instances are not protected by synchronization and
- * are not guaranteed to be thread-safe.  Therefore, if an instance of this class
- * is concurrently utilized by multiple threads, it is the responsibility of
- * client code to synchronize access to seeding and data generation methods.
- * </li>
- * </ul>
- * </p>
- * @since 3.1
- */
-public class RandomDataGenerator implements Serializable {
-
-    /** Serializable version identifier */
-    private static final long serialVersionUID = -626730818244969716L;
-
-    /** underlying random number generator */
-    private RandomGenerator rand;
-
-    /** underlying secure random number generator */
-    private RandomGenerator secRand = null;
-
-    /**
-     * Construct a RandomDataGenerator, using a default random generator as the source
-     * of randomness.
-     *
-     * <p>The default generator is a {@link Well19937c} seeded
-     * with {@code System.currentTimeMillis() + System.identityHashCode(this))}.
-     * The generator is initialized and seeded on first use.</p>
-     */
-    public RandomDataGenerator() {
-        rand = new Well19937c();
-    }
-
-    /**
-     * Construct a RandomDataGenerator using the supplied {@link RandomGenerator} as
-     * the source of (non-secure) random data.
-     *
-     * @param rand the source of (non-secure) random data
-     * (may be null, resulting in the default generator)
-     */
-    public RandomDataGenerator(RandomGenerator rand) {
-        this.rand = rand;
-    }
-
-    /**
-     * Generates a random string of hex characters of length {@code len}.
-     * <p>
-     * The generated string will be random, but not cryptographically secure. To generate
-     * cryptographically secure strings, use {@link #nextSecureHexString(int)}.
-     * <p>
-     * <strong>Algorithm Description:</strong> hex strings are generated using a
-     * 2-step process.
-     * <ol>
-     * <li>{@code len / 2 + 1} binary bytes are generated using the underlying
-     * Random</li>
-     * <li>Each binary byte is translated into 2 hex digits</li>
-     * </ol>
-     * </p>
-     *
-     * @param len the desired string length.
-     * @return the random string.
-     * @throws NotStrictlyPositiveException if {@code len <= 0}.
-     */
-    public String nextHexString(int len) throws NotStrictlyPositiveException {
-        if (len <= 0) {
-            throw new NotStrictlyPositiveException(LocalizedFormats.LENGTH, len);
-        }
-
-        // Get a random number generator
-        RandomGenerator ran = getRandomGenerator();
-
-        // Initialize output buffer
-        StringBuilder outBuffer = new StringBuilder();
-
-        // Get int(len/2)+1 random bytes
-        byte[] randomBytes = new byte[(len / 2) + 1];
-        ran.nextBytes(randomBytes);
-
-        // Convert each byte to 2 hex digits
-        for (int i = 0; i < randomBytes.length; i++) {
-            Integer c = Integer.valueOf(randomBytes[i]);
-
-            /*
-             * Add 128 to byte value to make interval 0-255 before doing hex
-             * conversion. This guarantees <= 2 hex digits from toHexString()
-             * toHexString would otherwise add 2^32 to negative arguments.
-             */
-            String hex = Integer.toHexString(c.intValue() + 128);
-
-            // Make sure we add 2 hex digits for each byte
-            if (hex.length() == 1) {
-                hex = "0" + hex;
-            }
-            outBuffer.append(hex);
-        }
-        return outBuffer.toString().substring(0, len);
-    }
-
-    /** Generates a uniformly distributed random integer between {@code lower}
-     * and {@code upper} (endpoints included).
-     * <p>
-     * The generated integer will be random, but not cryptographically secure.
-     * To generate cryptographically secure integer sequences, use
-     * {@link #nextSecureInt(int, int)}.
-     * </p>
-     *
-     * @param lower lower bound for generated integer
-     * @param upper upper bound for generated integer
-     * @return a random integer greater than or equal to {@code lower}
-     * and less than or equal to {@code upper}
-     * @throws NumberIsTooLargeException if {@code lower >= upper}
-     */
-    public int nextInt(final int lower, final int upper) throws NumberIsTooLargeException {
-        return new UniformIntegerDistribution(lower, upper).createSampler(getRandomProvider()).sample();
-    }
-
-    /** Generates a uniformly distributed random long integer between {@code lower}
-     * and {@code upper} (endpoints included).
-     * <p>
-     * The generated long integer will be random, but not cryptographically secure.
-     * To generate cryptographically secure long integer sequences, use
-     * {@link #nextSecureLong(long, long)}.
-     * </p>
-     *
-     * @param lower lower bound for generated long integer
-     * @param upper upper bound for generated long integer
-     * @return a random long integer greater than or equal to {@code lower}
-     * and less than or equal to {@code upper}
-     * @throws NumberIsTooLargeException if {@code lower >= upper}
-     */
-    public long nextLong(final long lower, final long upper) throws NumberIsTooLargeException {
-        if (lower >= upper) {
-            throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
-                                                lower, upper, false);
-        }
-        final long max = (upper - lower) + 1;
-        if (max <= 0) {
-            // the range is too wide to fit in a positive long (larger than 2^63); as it covers
-            // more than half the long range, we use directly a simple rejection method
-            final RandomGenerator rng = getRandomGenerator();
-            while (true) {
-                final long r = rng.nextLong();
-                if (r >= lower && r <= upper) {
-                    return r;
-                }
-            }
-        } else if (max < Integer.MAX_VALUE){
-            // we can shift the range and generate directly a positive int
-            return lower + getRandomGenerator().nextInt((int) max);
-        } else {
-            // we can shift the range and generate directly a positive long
-            return lower + nextLong(getRandomGenerator(), max);
-        }
-    }
-
-    /**
-     * Returns a pseudorandom, uniformly distributed {@code long} value
-     * between 0 (inclusive) and the specified value (exclusive), drawn from
-     * this random number generator's sequence.
-     *
-     * @param rng random generator to use
-     * @param n the bound on the random number to be returned.  Must be
-     * positive.
-     * @return  a pseudorandom, uniformly distributed {@code long}
-     * value between 0 (inclusive) and n (exclusive).
-     * @throws IllegalArgumentException  if n is not positive.
-     */
-    private static long nextLong(final RandomGenerator rng, final long n) throws IllegalArgumentException {
-        if (n > 0) {
-            final byte[] byteArray = new byte[8];
-            long bits;
-            long val;
-            do {
-                rng.nextBytes(byteArray);
-                bits = 0;
-                for (final byte b : byteArray) {
-                    bits = (bits << 8) | (((long) b) & 0xffL);
-                }
-                bits &= 0x7fffffffffffffffL;
-                val  = bits % n;
-            } while (bits - val + (n - 1) < 0);
-            return val;
-        }
-        throw new NotStrictlyPositiveException(n);
-    }
-
-    /**
-     * Generates a random string of hex characters from a secure random
-     * sequence.
-     * <p>
-     * If cryptographic security is not required, use
-     * {@link #nextHexString(int)}.
-     * </p>
-     * <p>
-     * <strong>Algorithm Description:</strong> hex strings are generated in
-     * 40-byte segments using a 3-step process.
-     * <ol>
-     * <li>
-     * 20 random bytes are generated using the underlying
-     * <code>SecureRandom</code>.</li>
-     * <li>
-     * SHA-1 hash is applied to yield a 20-byte binary digest.</li>
-     * <li>
-     * Each byte of the binary digest is converted to 2 hex digits.</li>
-     * </ol>
-     * </p>
-     * @param len the length of the string to be generated
-     * @return a random string of hex characters of length {@code len}
-     * @throws NotStrictlyPositiveException if {@code len <= 0}
-     */
-    public String nextSecureHexString(int len) throws NotStrictlyPositiveException {
-        if (len <= 0) {
-            throw new NotStrictlyPositiveException(LocalizedFormats.LENGTH, len);
-        }
-
-        // Get SecureRandom and setup Digest provider
-        final RandomGenerator secRan = getSecRan();
-        MessageDigest alg = null;
-        try {
-            alg = MessageDigest.getInstance("SHA-1");
-        } catch (NoSuchAlgorithmException ex) {
-            // this should never happen
-            throw new MathInternalError(ex);
-        }
-        alg.reset();
-
-        // Compute number of iterations required (40 bytes each)
-        int numIter = (len / 40) + 1;
-
-        StringBuilder outBuffer = new StringBuilder();
-        for (int iter = 1; iter < numIter + 1; iter++) {
-            byte[] randomBytes = new byte[40];
-            secRan.nextBytes(randomBytes);
-            alg.update(randomBytes);
-
-            // Compute hash -- will create 20-byte binary hash
-            byte[] hash = alg.digest();
-
-            // Loop over the hash, converting each byte to 2 hex digits
-            for (int i = 0; i < hash.length; i++) {
-                Integer c = Integer.valueOf(hash[i]);
-
-                /*
-                 * Add 128 to byte value to make interval 0-255 This guarantees
-                 * <= 2 hex digits from toHexString() toHexString would
-                 * otherwise add 2^32 to negative arguments
-                 */
-                String hex = Integer.toHexString(c.intValue() + 128);
-
-                // Keep strings uniform length -- guarantees 40 bytes
-                if (hex.length() == 1) {
-                    hex = "0" + hex;
-                }
-                outBuffer.append(hex);
-            }
-        }
-        return outBuffer.toString().substring(0, len);
-    }
-
-    /**
-     * Generates a uniformly distributed random integer between {@code lower}
-     * and {@code upper} (endpoints included) from a secure random sequence.
-     * <p>
-     * Sequences of integers generated using this method will be
-     * cryptographically secure. If cryptographic security is not required,
-     * {@link #nextInt(int, int)} should be used instead of this method.</p>
-     * <p>
-     * <strong>Definition</strong>:
-     * <a href="http://en.wikipedia.org/wiki/Cryptographically_secure_pseudo-random_number_generator">
-     * Secure Random Sequence</a></p>
-     *
-     * @param lower lower bound for generated integer
-     * @param upper upper bound for generated integer
-     * @return a random integer greater than or equal to {@code lower} and less
-     * than or equal to {@code upper}.
-     * @throws NumberIsTooLargeException if {@code lower >= upper}.
-     */
-    public int nextSecureInt(final int lower, final int upper) throws NumberIsTooLargeException {
-        return new UniformIntegerDistribution(lower, upper).createSampler(getSecureRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a uniformly distributed random long integer between
-     * {@code lower} and {@code upper} (endpoints included) from a secure random
-     * sequence.
-     * <p>
-     * Sequences of long values generated using this method will be
-     * cryptographically secure. If cryptographic security is not required,
-     * {@link #nextLong(long, long)} should be used instead of this method.</p>
-     * <p>
-     * <strong>Definition</strong>:
-     * <a href="http://en.wikipedia.org/wiki/Cryptographically_secure_pseudo-random_number_generator">
-     * Secure Random Sequence</a></p>
-     *
-     * @param lower lower bound for generated integer
-     * @param upper upper bound for generated integer
-     * @return a random long integer greater than or equal to {@code lower} and
-     * less than or equal to {@code upper}.
-     * @throws NumberIsTooLargeException if {@code lower >= upper}.
-     */
-    public long nextSecureLong(final long lower, final long upper) throws NumberIsTooLargeException {
-        if (lower >= upper) {
-            throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
-                                                lower, upper, false);
-        }
-        final RandomGenerator rng = getSecRan();
-        final long max = (upper - lower) + 1;
-        if (max <= 0) {
-            // the range is too wide to fit in a positive long (larger than 2^63); as it covers
-            // more than half the long range, we use directly a simple rejection method
-            while (true) {
-                final long r = rng.nextLong();
-                if (r >= lower && r <= upper) {
-                    return r;
-                }
-            }
-        } else if (max < Integer.MAX_VALUE){
-            // we can shift the range and generate directly a positive int
-            return lower + rng.nextInt((int) max);
-        } else {
-            // we can shift the range and generate directly a positive long
-            return lower + nextLong(rng, max);
-        }
-    }
-
-    /**
-     * Generates a random value from the Poisson distribution with the given
-     * mean.
-     * <p>
-     * <strong>Definition</strong>:
-     * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda366j.htm">
-     * Poisson Distribution</a></p>
-     * <p>
-     * <strong>Algorithm Description</strong>:
-     * <ul><li> For small means, uses simulation of a Poisson process
-     * using Uniform deviates, as described
-     * <a href="http://irmi.epfl.ch/cmos/Pmmi/interactive/rng7.htm"> here.</a>
-     * The Poisson process (and hence value returned) is bounded by 1000 * mean.</li>
-     *
-     * <li> For large means, uses the rejection algorithm described in <br/>
-     * Devroye, Luc. (1981).<i>The Computer Generation of Poisson Random Variables</i>
-     * <strong>Computing</strong> vol. 26 pp. 197-207.</li></ul></p>
-     *
-     * @param mean the mean of the Poisson distribution
-     * @return a random value following the specified Poisson distribution
-     * @throws NotStrictlyPositiveException if {@code mean <= 0}.
-     */
-    public long nextPoisson(double mean) throws NotStrictlyPositiveException {
-        return new PoissonDistribution(mean,
-                PoissonDistribution.DEFAULT_EPSILON,
-                PoissonDistribution.DEFAULT_MAX_ITERATIONS).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the Normal (or Gaussian) distribution with
-     * specified mean and standard deviation.
-     * <p>
-     * <strong>Definition</strong>:
-     * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3661.htm">
-     * Normal Distribution</a></p>
-     *
-     * @param mu the mean of the distribution
-     * @param sigma the standard deviation of the distribution
-     * @return a random value following the specified Gaussian distribution
-     * @throws NotStrictlyPositiveException if {@code sigma <= 0}.
-     */
-    public double nextGaussian(double mu, double sigma) throws NotStrictlyPositiveException {
-        if (sigma <= 0) {
-            throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sigma);
-        }
-        return sigma * getRandomGenerator().nextGaussian() + mu;
-    }
-
-    /**
-     * Generates a random value from the exponential distribution
-     * with specified mean.
-     * <p>
-     * <strong>Definition</strong>:
-     * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3667.htm">
-     * Exponential Distribution</a></p>
-     * <p>
-     * <strong>Algorithm Description</strong>: Uses the Algorithm SA (Ahrens)
-     * from p. 876 in:
-     * [1]: Ahrens, J. H. and Dieter, U. (1972). Computer methods for
-     * sampling from the exponential and normal distributions.
-     * Communications of the ACM, 15, 873-882.
-     * </p>
-     *
-     * @param mean the mean of the distribution
-     * @return a random value following the specified exponential distribution
-     * @throws NotStrictlyPositiveException if {@code mean <= 0}.
-     */
-    public double nextExponential(double mean) throws NotStrictlyPositiveException {
-        return new ExponentialDistribution(mean, ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * <p>Generates a random value from the
-     * {@link org.apache.commons.math4.distribution.GammaDistribution Gamma Distribution}.</p>
-     *
-     * <p>This implementation uses the following algorithms: </p>
-     *
-     * <p>For 0 < shape < 1: <br/>
-     * Ahrens, J. H. and Dieter, U., <i>Computer methods for
-     * sampling from gamma, beta, Poisson and binomial distributions.</i>
-     * Computing, 12, 223-246, 1974.</p>
-     *
-     * <p>For shape >= 1: <br/>
-     * Marsaglia and Tsang, <i>A Simple Method for Generating
-     * Gamma Variables.</i> ACM Transactions on Mathematical Software,
-     * Volume 26 Issue 3, September, 2000.</p>
-     *
-     * @param shape the median of the Gamma distribution
-     * @param scale the scale parameter of the Gamma distribution
-     * @return random value sampled from the Gamma(shape, scale) distribution
-     * @throws NotStrictlyPositiveException if {@code shape <= 0} or
-     * {@code scale <= 0}.
-     */
-    public double nextGamma(double shape, double scale) throws NotStrictlyPositiveException {
-        return new GammaDistribution(shape, scale, GammaDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the {@link HypergeometricDistribution Hypergeometric Distribution}.
-     *
-     * @param populationSize the population size of the Hypergeometric distribution
-     * @param numberOfSuccesses number of successes in the population of the Hypergeometric distribution
-     * @param sampleSize the sample size of the Hypergeometric distribution
-     * @return random value sampled from the Hypergeometric(numberOfSuccesses, sampleSize) distribution
-     * @throws NumberIsTooLargeException  if {@code numberOfSuccesses > populationSize},
-     * or {@code sampleSize > populationSize}.
-     * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
-     * @throws NotPositiveException  if {@code numberOfSuccesses < 0}.
-     */
-    public int nextHypergeometric(int populationSize, int numberOfSuccesses, int sampleSize) throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
-        return new HypergeometricDistribution(populationSize, numberOfSuccesses, sampleSize).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the {@link PascalDistribution Pascal Distribution}.
-     *
-     * @param r the number of successes of the Pascal distribution
-     * @param p the probability of success of the Pascal distribution
-     * @return random value sampled from the Pascal(r, p) distribution
-     * @throws NotStrictlyPositiveException if the number of successes is not positive
-     * @throws OutOfRangeException if the probability of success is not in the
-     * range {@code [0, 1]}.
-     */
-    public int nextPascal(int r, double p) throws NotStrictlyPositiveException, OutOfRangeException {
-        return new PascalDistribution(r, p).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the {@link TDistribution T Distribution}.
-     *
-     * @param df the degrees of freedom of the T distribution
-     * @return random value from the T(df) distribution
-     * @throws NotStrictlyPositiveException if {@code df <= 0}
-     */
-    public double nextT(double df) throws NotStrictlyPositiveException {
-        return new TDistribution(df, TDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the {@link WeibullDistribution Weibull Distribution}.
-     *
-     * @param shape the shape parameter of the Weibull distribution
-     * @param scale the scale parameter of the Weibull distribution
-     * @return random value sampled from the Weibull(shape, size) distribution
-     * @throws NotStrictlyPositiveException if {@code shape <= 0} or
-     * {@code scale <= 0}.
-     */
-    public double nextWeibull(double shape, double scale) throws NotStrictlyPositiveException {
-        return new WeibullDistribution(shape, scale, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the {@link ZipfDistribution Zipf Distribution}.
-     *
-     * @param numberOfElements the number of elements of the ZipfDistribution
-     * @param exponent the exponent of the ZipfDistribution
-     * @return random value sampled from the Zipf(numberOfElements, exponent) distribution
-     * @exception NotStrictlyPositiveException if {@code numberOfElements <= 0}
-     * or {@code exponent <= 0}.
-     */
-    public int nextZipf(int numberOfElements, double exponent) throws NotStrictlyPositiveException {
-        return new ZipfDistribution(numberOfElements, exponent).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the {@link BetaDistribution Beta Distribution}.
-     *
-     * @param alpha first distribution shape parameter
-     * @param beta second distribution shape parameter
-     * @return random value sampled from the beta(alpha, beta) distribution
-     */
-    public double nextBeta(double alpha, double beta) {
-        return new BetaDistribution(alpha, beta, BetaDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the {@link BinomialDistribution Binomial Distribution}.
-     *
-     * @param numberOfTrials number of trials of the Binomial distribution
-     * @param probabilityOfSuccess probability of success of the Binomial distribution
-     * @return random value sampled from the Binomial(numberOfTrials, probabilityOfSuccess) distribution
-     */
-    public int nextBinomial(int numberOfTrials, double probabilityOfSuccess) {
-        return new BinomialDistribution(numberOfTrials, probabilityOfSuccess).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the {@link CauchyDistribution Cauchy Distribution}.
-     *
-     * @param median the median of the Cauchy distribution
-     * @param scale the scale parameter of the Cauchy distribution
-     * @return random value sampled from the Cauchy(median, scale) distribution
-     */
-    public double nextCauchy(double median, double scale) {
-        return new CauchyDistribution(median, scale, CauchyDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the {@link ChiSquaredDistribution ChiSquare Distribution}.
-     *
-     * @param df the degrees of freedom of the ChiSquare distribution
-     * @return random value sampled from the ChiSquare(df) distribution
-     */
-    public double nextChiSquare(double df) {
-        return new ChiSquaredDistribution(df, ChiSquaredDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a random value from the {@link FDistribution F Distribution}.
-     *
-     * @param numeratorDf the numerator degrees of freedom of the F distribution
-     * @param denominatorDf the denominator degrees of freedom of the F distribution
-     * @return random value sampled from the F(numeratorDf, denominatorDf) distribution
-     * @throws NotStrictlyPositiveException if
-     * {@code numeratorDf <= 0} or {@code denominatorDf <= 0}.
-     */
-    public double nextF(double numeratorDf, double denominatorDf) throws NotStrictlyPositiveException {
-        return new FDistribution(numeratorDf, denominatorDf, FDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).createSampler(getRandomProvider()).sample();
-    }
-
-    /**
-     * Generates a uniformly distributed random value from the open interval
-     * {@code (lower, upper)} (i.e., endpoints excluded).
-     * <p>
-     * <strong>Definition</strong>:
-     * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3662.htm">
-     * Uniform Distribution</a> {@code lower} and {@code upper - lower} are the
-     * <a href = "http://www.itl.nist.gov/div898/handbook/eda/section3/eda364.htm">
-     * location and scale parameters</a>, respectively.</p>
-     * <p>
-     * <strong>Algorithm Description</strong>: scales the output of
-     * Random.nextDouble(), but rejects 0 values (i.e., will generate another
-     * random double if Random.nextDouble() returns 0). This is necessary to
-     * provide a symmetric output interval (both endpoints excluded).
-     * </p>
-     *
-     * @param lower the exclusive lower bound of the support
-     * @param upper the exclusive upper bound of the support
-     * @return a uniformly distributed random value between lower and upper
-     * (exclusive)
-     * @throws NumberIsTooLargeException if {@code lower >= upper}
-     * @throws NotFiniteNumberException if one of the bounds is infinite
-     * @throws NotANumberException if one of the bounds is NaN
-     */
-    public double nextUniform(double lower, double upper)
-            throws NumberIsTooLargeException, NotFiniteNumberException, NotANumberException {
-        return nextUniform(lower, upper, false);
-    }
-
-    /**
-     * Generates a uniformly distributed random value from the interval
-     * {@code (lower, upper)} or the interval {@code [lower, upper)}. The lower
-     * bound is thus optionally included, while the upper bound is always
-     * excluded.
-     * <p>
-     * <strong>Definition</strong>:
-     * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3662.htm">
-     * Uniform Distribution</a> {@code lower} and {@code upper - lower} are the
-     * <a href = "http://www.itl.nist.gov/div898/handbook/eda/section3/eda364.htm">
-     * location and scale parameters</a>, respectively.</p>
-     * <p>
-     * <strong>Algorithm Description</strong>: if the lower bound is excluded,
-     * scales the output of Random.nextDouble(), but rejects 0 values (i.e.,
-     * will generate another random double if Random.nextDouble() returns 0).
-     * This is necessary to provide a symmetric output interval (both
-     * endpoints excluded).
-     * </p>
-     *
-     *
-     * @param lower the lower bound of the support
-     * @param upper the exclusive upper bound of the support
-     * @param lowerInclusive {@code true} if the lower bound is inclusive
-     * @return uniformly distributed random value in the {@code (lower, upper)}
-     * interval, if {@code lowerInclusive} is {@code false}, or in the
-     * {@code [lower, upper)} interval, if {@code lowerInclusive} is
-     * {@code true}
-     * @throws NumberIsTooLargeException if {@code lower >= upper}
-     * @throws NotFiniteNumberException if one of the bounds is infinite
-     * @throws NotANumberException if one of the bounds is NaN
-     */
-    public double nextUniform(double lower, double upper, boolean lowerInclusive)
-        throws NumberIsTooLargeException, NotFiniteNumberException, NotANumberException {
-
-        if (lower >= upper) {
-            throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
-                                                lower, upper, false);
-        }
-
-        if (Double.isInfinite(lower)) {
-            throw new NotFiniteNumberException(LocalizedFormats.INFINITE_BOUND, lower);
-        }
-        if (Double.isInfinite(upper)) {
-            throw new NotFiniteNumberException(LocalizedFormats.INFINITE_BOUND, upper);
-        }
-
-        if (Double.isNaN(lower) || Double.isNaN(upper)) {
-            throw new NotANumberException();
-        }
-
-        final RandomGenerator generator = getRandomGenerator();
-
-        // ensure nextDouble() isn't 0.0
-        double u = generator.nextDouble();
-        while (!lowerInclusive && u <= 0.0) {
-            u = generator.nextDouble();
-        }
-
-        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>
-     * 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 }}.
-     *
-     *
-     * @param n the domain of the permutation
-     * @param k the 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);
-        }
-
-        int[] index = MathArrays.natural(n);
-        MathArrays.shuffle(index, getRandomProvider());
-
-        // Return a new array containing the first "k" entries of "index".
-        return MathArrays.copyOf(index, k);
-    }
-
-    /**
-     * Returns an array of {@code k} objects selected randomly from the
-     * Collection {@code c}.
-     * <p>
-     * Sampling from {@code c} is without replacement; but if {@code c} contains
-     * identical objects, the sample may include repeats.  If all elements of
-     * {@code c} 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
-     * {@code c}.</p>
-     * <p>This method calls {@link #nextPermutation(int,int) nextPermutation(c.size(), k)}
-     * in order to sample the collection.
-     * </p>
-     *
-     * @param c the collection to be sampled
-     * @param k the size of the sample
-     * @return a random sample of {@code k} elements from {@code c}
-     * @throws NumberIsTooLargeException if {@code k > c.size()}.
-     * @throws NotStrictlyPositiveException if {@code k <= 0}.
-     */
-    public Object[] nextSample(Collection<?> c, int k) throws NumberIsTooLargeException, NotStrictlyPositiveException {
-
-        int len = c.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);
-        }
-
-        Object[] objects = c.toArray();
-        int[] index = nextPermutation(len, k);
-        Object[] result = new Object[k];
-        for (int i = 0; i < k; i++) {
-            result[i] = objects[index[i]];
-        }
-        return result;
-    }
-
-
-
-    /**
-     * Reseeds the random number generator with the supplied seed.
-     * <p>
-     * Will create and initialize if null.
-     * </p>
-     *
-     * @param seed the seed value to use
-     */
-    public void reSeed(long seed) {
-        getRandomGenerator().setSeed(seed);
-    }
-
-    /**
-     * Reseeds the secure random number generator with the current time in
-     * milliseconds.
-     * <p>
-     * Will create and initialize if null.
-     * </p>
-     */
-    public void reSeedSecure() {
-        getSecRan().setSeed(System.currentTimeMillis());
-    }
-
-    /**
-     * Reseeds the secure random number generator with the supplied seed.
-     * <p>
-     * Will create and initialize if null.
-     * </p>
-     *
-     * @param seed the seed value to use
-     */
-    public void reSeedSecure(long seed) {
-        getSecRan().setSeed(seed);
-    }
-
-    /**
-     * Reseeds the random number generator with
-     * {@code System.currentTimeMillis() + System.identityHashCode(this))}.
-     */
-    public void reSeed() {
-        reSeed(System.currentTimeMillis() + System.identityHashCode(this));
-    }
-
-    /**
-     * Sets the PRNG algorithm for the underlying SecureRandom instance using
-     * the Security Provider API. The Security Provider API is defined in <a
-     * href =
-     * "http://java.sun.com/j2se/1.3/docs/guide/security/CryptoSpec.html#AppA">
-     * Java Cryptography Architecture API Specification & Reference.</a>
-     * <p>
-     * <strong>USAGE NOTE:</strong> This method carries <i>significant</i>
-     * overhead and may take several seconds to execute.
-     * </p>
-     *
-     * @param algorithm the name of the PRNG algorithm
-     * @param provider the name of the provider
-     * @throws NoSuchAlgorithmException if the specified algorithm is not available
-     * @throws NoSuchProviderException if the specified provider is not installed
-     */
-    public void setSecureAlgorithm(String algorithm, String provider)
-            throws NoSuchAlgorithmException, NoSuchProviderException {
-        secRand = RandomGeneratorFactory.createRandomGenerator(SecureRandom.getInstance(algorithm, provider));
-    }
-
-    /**
-     * Returns the RandomGenerator used to generate non-secure random data.
-     * <p>
-     * Creates and initializes a default generator if null. Uses a {@link Well19937c}
-     * generator with {@code System.currentTimeMillis() + System.identityHashCode(this))}
-     * as the default seed.
-     * </p>
-     *
-     * @return the Random used to generate random data
-     * @since 3.2
-     */
-    public RandomGenerator getRandomGenerator() {
-        if (rand == null) {
-            initRan();
-        }
-        return rand;
-    }
-
-    /**
-     * @param rng {@link RandomGenerator} instance.
-     * @return a {@link UniformRandomProvider} instance.
-     */
-    private UniformRandomProvider wrapRandomGenerator(final RandomGenerator rng) {
-        return new UniformRandomProvider() {
-            /** {@inheritDoc} */
-            @Override
-            public void nextBytes(byte[] bytes) {
-                rng.nextBytes(bytes);
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public void nextBytes(byte[] bytes,
-                                  int start,
-                                  int len) {
-                throw new MathInternalError();
-            }
-
-            /** {@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
-            public long nextLong(long n) {
-                throw new MathInternalError();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public boolean nextBoolean() {
-                return rng.nextBoolean();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public float nextFloat() {
-                return rng.nextFloat();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public double nextDouble() {
-                return rng.nextDouble();
-            }
-        };
-    }
-
-    /**
-     * @return the generator used to generate secure random data.
-     */
-    private UniformRandomProvider getSecureRandomProvider() {
-        return wrapRandomGenerator(getSecRan());
-    }
-
-    /**
-     * @return the generator used to generate non-secure random data.
-     *
-     * XXX TODO: method cannot be "private" because of its use in "ValueServer" in "DIGEST_MODE".
-     * "ValueServer" should be fixed to not use the internals of another class!
-     */
-    UniformRandomProvider getRandomProvider() {
-        return wrapRandomGenerator(getRandomGenerator());
-    }
-
-    /**
-     * Sets the default generator to a {@link Well19937c} generator seeded with
-     * {@code System.currentTimeMillis() + System.identityHashCode(this))}.
-     */
-    private void initRan() {
-        rand = new Well19937c(System.currentTimeMillis() + System.identityHashCode(this));
-    }
-
-    /**
-     * Returns the SecureRandom used to generate secure random data.
-     * <p>
-     * Creates and initializes if null.  Uses
-     * {@code System.currentTimeMillis() + System.identityHashCode(this)} as the default seed.
-     * </p>
-     *
-     * @return the SecureRandom used to generate secure random data, wrapped in a
-     * {@link RandomGenerator}.
-     */
-    private RandomGenerator getSecRan() {
-        if (secRand == null) {
-            secRand = RandomGeneratorFactory.createRandomGenerator(new SecureRandom());
-            secRand.setSeed(System.currentTimeMillis() + System.identityHashCode(this));
-        }
-        return secRand;
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/7550cb46/src/main/java/org/apache/commons/math4/random/Well19937c.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/Well19937c.java b/src/main/java/org/apache/commons/math4/random/Well19937c.java
deleted file mode 100644
index 1ff77c7..0000000
--- a/src/main/java/org/apache/commons/math4/random/Well19937c.java
+++ /dev/null
@@ -1,115 +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;
-
-
-/** This class implements the WELL19937c pseudo-random number generator
- * from Fran&ccedil;ois Panneton, Pierre L'Ecuyer and Makoto Matsumoto.
- * <p>
- * This generator is described in a paper by Fran&ccedil;ois Panneton,
- * Pierre L'Ecuyer and Makoto Matsumoto <a
- * href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf">Improved
- * Long-Period Generators Based on Linear Recurrences Modulo 2</a> ACM
- * Transactions on Mathematical Software, 32, 1 (2006). The errata for the paper
- * are in <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng-errata.txt">wellrng-errata.txt</a>.</p>
- *
- * @see <a href="http://www.iro.umontreal.ca/~panneton/WELLRNG.html">WELL Random number generator</a>
- * @since 2.2
- */
-public class Well19937c extends AbstractWell {
-
-    /** Serializable version identifier. */
-    private static final long serialVersionUID = 20150223L;
-
-    /** Number of bits in the pool. */
-    private static final int K = 19937;
-
-    /** First parameter of the algorithm. */
-    private static final int M1 = 70;
-
-    /** Second parameter of the algorithm. */
-    private static final int M2 = 179;
-
-    /** Third parameter of the algorithm. */
-    private static final int M3 = 449;
-
-    /** The indirection index table. */
-    private static final IndexTable TABLE = new IndexTable(K, M1, M2, M3);
-
-    /** Creates a new random number generator.
-     * <p>The instance is initialized using the current time as the
-     * seed.</p>
-     */
-    public Well19937c() {
-        super(K);
-    }
-
-    /** Creates a new random number generator using a single int seed.
-     * @param seed the initial seed (32 bits integer)
-     */
-    public Well19937c(int seed) {
-        super(K, seed);
-    }
-
-    /** Creates a new random number generator using an int array seed.
-     * @param seed the initial seed (32 bits integers array), if null
-     * the seed of the generator will be related to the current time
-     */
-    public Well19937c(int[] seed) {
-        super(K, seed);
-    }
-
-    /** Creates a new random number generator using a single long seed.
-     * @param seed the initial seed (64 bits integer)
-     */
-    public Well19937c(long seed) {
-        super(K, seed);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected int next(final int bits) {
-
-        final int indexRm1 = TABLE.getIndexPred(index);
-        final int indexRm2 = TABLE.getIndexPred2(index);
-
-        final int v0       = v[index];
-        final int vM1      = v[TABLE.getIndexM1(index)];
-        final int vM2      = v[TABLE.getIndexM2(index)];
-        final int vM3      = v[TABLE.getIndexM3(index)];
-
-        final int z0 = (0x80000000 & v[indexRm1]) ^ (0x7FFFFFFF & v[indexRm2]);
-        final int z1 = (v0 ^ (v0 << 25))  ^ (vM1 ^ (vM1 >>> 27));
-        final int z2 = (vM2 >>> 9) ^ (vM3 ^ (vM3 >>> 1));
-        final int z3 = z1      ^ z2;
-        int z4 = z0 ^ (z1 ^ (z1 << 9)) ^ (z2 ^ (z2 << 21)) ^ (z3 ^ (z3 >>> 21));
-
-        v[index]     = z3;
-        v[indexRm1]  = z4;
-        v[indexRm2] &= 0x80000000;
-        index        = indexRm1;
-
-        // add Matsumoto-Kurita tempering
-        // to get a maximally-equidistributed generator
-        z4 ^= (z4 <<  7) & 0xe46e1700;
-        z4 ^= (z4 << 15) & 0x9b868000;
-
-        return z4 >>> (32 - bits);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/7550cb46/src/test/java/org/apache/commons/math4/random/BitsStreamGeneratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/BitsStreamGeneratorTest.java b/src/test/java/org/apache/commons/math4/random/BitsStreamGeneratorTest.java
deleted file mode 100644
index 7f43ccb..0000000
--- a/src/test/java/org/apache/commons/math4/random/BitsStreamGeneratorTest.java
+++ /dev/null
@@ -1,86 +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.random.BitsStreamGenerator;
-import org.apache.commons.math4.random.RandomGenerator;
-
-/**
- * Test cases for the BitStreamGenerator class
- *
- */
-
-public class BitsStreamGeneratorTest extends RandomGeneratorAbstractTest {
-
-    public BitsStreamGeneratorTest() {
-        super();
-    }
-
-    @Override
-    protected RandomGenerator makeGenerator() {
-        RandomGenerator generator = new TestBitStreamGenerator();
-        generator.setSeed(1000);
-        return generator;
-    }
-
-    /**
-     * Test BitStreamGenerator using a Random as bit source.
-     */
-    static class TestBitStreamGenerator extends BitsStreamGenerator {
-
-        private static final long serialVersionUID = 1L;
-        private BitRandom ran = new BitRandom();
-
-        @Override
-        public void setSeed(int seed) {
-           ran.setSeed(seed);
-           clear();
-        }
-
-        @Override
-        public void setSeed(int[] seed) {
-            ran.setSeed(seed[0]);
-        }
-
-        @Override
-        public void setSeed(long seed) {
-            ran.setSeed((int) seed);
-
-        }
-
-        @Override
-        protected int next(int bits) {
-            return ran.nextBits(bits);
-        }
-    }
-
-    /**
-     * Extend Random to expose next(bits)
-     */
-    @SuppressWarnings("serial")
-    static class BitRandom extends Random {
-        public BitRandom() {
-            super();
-        }
-        public int nextBits(int bits) {
-            return next(bits);
-        }
-    }
-
-}


[4/5] [math] Removed obsolete tests (cf. MATH-1158).

Posted by er...@apache.org.
Removed obsolete tests (cf. MATH-1158).


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

Branch: refs/heads/task-MATH-1366
Commit: 47c41fe3071c2aee40fa2a158eddb0ffcfff22b5
Parents: 7550cb4
Author: Gilles <er...@apache.org>
Authored: Fri May 20 14:24:00 2016 +0200
Committer: Gilles <er...@apache.org>
Committed: Fri May 20 14:24:00 2016 +0200

----------------------------------------------------------------------
 .../math4/random/EmpiricalDistributionTest.java | 33 --------------------
 1 file changed, 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/47c41fe3/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java b/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
index 3c0564f..c23b477 100644
--- a/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
+++ b/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
@@ -257,39 +257,6 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         TestUtils.assertEquals(expectedGeneratorUpperBounds, dist.getGeneratorUpperBounds(), tol);
     }
 
-    // XXX REMOVE (test "embedded RNG" which is to be removed)
-//     @Test
-//     public void testGeneratorConfig() {
-//         double[] testData = {0, 1, 2, 3, 4};
-//         RandomGenerator generator = new RandomAdaptorTest.ConstantGenerator(0.5);
-
-//         EmpiricalDistribution dist = new EmpiricalDistribution(5, generator);
-//         dist.load(testData);
-//         for (int i = 0; i < 5; i++) {
-//             Assert.assertEquals(2.0, dist.getNextValue(), 0d);
-//         }
-
-//         // Verify no NPE with null generator argument
-//         dist = new EmpiricalDistribution(5, (RandomGenerator) null);
-//         dist.load(testData);
-//         dist.getNextValue();
-//     }
-
-    // XXX REMOVE (test "embedded RNG" which is to be removed)
-//     @Test
-//     public void testReSeed() throws Exception {
-//         empiricalDistribution.load(url);
-//         empiricalDistribution.reSeed(100);
-//         final double [] values = new double[10];
-//         for (int i = 0; i < 10; i++) {
-//             values[i] = empiricalDistribution.getNextValue();
-//         }
-//         empiricalDistribution.reSeed(100);
-//         for (int i = 0; i < 10; i++) {
-//             Assert.assertEquals(values[i],empiricalDistribution.getNextValue(), 0d);
-//         }
-//     }
-
     private void verifySame(EmpiricalDistribution d1, EmpiricalDistribution d2) {
         Assert.assertEquals(d1.isLoaded(), d2.isLoaded());
         Assert.assertEquals(d1.getBinCount(), d2.getBinCount());


[5/5] [math] MATH-1366

Posted by er...@apache.org.
MATH-1366

Obsolete class removed (replaced by method "asUniformRandomProvider" in "RandomUtils").


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

Branch: refs/heads/task-MATH-1366
Commit: 34eba8132225fcdae317a26dd178901bf9fd437f
Parents: 47c41fe
Author: Gilles <er...@apache.org>
Authored: Fri May 20 14:32:30 2016 +0200
Committer: Gilles <er...@apache.org>
Committed: Fri May 20 14:32:30 2016 +0200

----------------------------------------------------------------------
 .../math4/random/RandomGeneratorFactory.java    | 133 -------------------
 1 file changed, 133 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/34eba813/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java b/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java
deleted file mode 100644
index 287b7ad..0000000
--- a/src/main/java/org/apache/commons/math4/random/RandomGeneratorFactory.java
+++ /dev/null
@@ -1,133 +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.NotStrictlyPositiveException;
-
-/**
- * Utilities for creating {@link RandomGenerator} instances.
- *
- * @since 3.3
- */
-public class RandomGeneratorFactory {
-    /**
-     * Class contains only static methods.
-     */
-    private RandomGeneratorFactory() {}
-
-    /**
-     * Creates a {@link RandomGenerator} instance that wraps a
-     * {@link Random} instance.
-     *
-     * @param rng JDK {@link Random} instance that will generate the
-     * the random data.
-     * @return the given RNG, wrapped in a {@link RandomGenerator}.
-     */
-    public static RandomGenerator createRandomGenerator(final Random rng) {
-        return new RandomGenerator() {
-            /** {@inheritDoc} */
-            @Override
-            public void setSeed(int seed) {
-                rng.setSeed((long) seed);
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public void setSeed(int[] seed) {
-                rng.setSeed(convertToLong(seed));
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public void setSeed(long seed) {
-                rng.setSeed(seed);
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public void nextBytes(byte[] bytes) {
-                rng.nextBytes(bytes);
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public int nextInt() {
-                return rng.nextInt();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public int nextInt(int n) {
-                if (n <= 0) {
-                    throw new NotStrictlyPositiveException(n);
-                }
-                return rng.nextInt(n);
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public long nextLong() {
-                return rng.nextLong();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public boolean nextBoolean() {
-                return rng.nextBoolean();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public float nextFloat() {
-                return rng.nextFloat();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public double nextDouble() {
-                return rng.nextDouble();
-            }
-
-            /** {@inheritDoc} */
-            @Override
-            public double nextGaussian() {
-                return rng.nextGaussian();
-            }
-        };
-    }
-
-    /**
-     * Converts seed from one representation to another.
-     *
-     * @param seed Original seed.
-     * @return the converted seed.
-     */
-    public static long convertToLong(int[] seed) {
-        // The following number is the largest prime that fits
-        // in 32 bits (i.e. 2^32 - 5).
-        final long prime = 4294967291l;
-
-        long combined = 0l;
-        for (int s : seed) {
-            combined = combined * prime + s;
-        }
-
-        return combined;
-    }
-}