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/29 21:01:43 UTC

[18/32] [math] MATH-1366

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/develop
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);
-        }
-    }
-
-}