diff --git a/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java b/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java index f584253f2..1f6c006f7 100644 --- a/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java @@ -48,23 +48,15 @@ public abstract class AbstractRealDistribution /** Default absolute accuracy for inverse cumulative computation. */ public static final double SOLVER_DEFAULT_ABSOLUTE_ACCURACY = 1e-6; /** Serializable version identifier */ - private static final long serialVersionUID = -38038050983108802L; + private static final long serialVersionUID = 20160311L; /** * RNG instance used to generate samples from the distribution. * @since 3.1 + * XXX: hard-coded value to prevent "NullPointerException". */ @Deprecated - protected final RandomGenerator random; - - /** - * @param rng Random number generator. - * @since 3.1 - */ - @Deprecated - protected AbstractRealDistribution(RandomGenerator rng) { - random = rng; - } + protected final RandomGenerator random = new org.apache.commons.math4.random.Well19937c(); /** * For a random variable {@code X} whose values are distributed according diff --git a/src/main/java/org/apache/commons/math4/distribution/BetaDistribution.java b/src/main/java/org/apache/commons/math4/distribution/BetaDistribution.java index 3009abfe9..0644eb128 100644 --- a/src/main/java/org/apache/commons/math4/distribution/BetaDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/BetaDistribution.java @@ -18,8 +18,6 @@ package org.apache.commons.math4.distribution; import org.apache.commons.math4.exception.NumberIsTooSmallException; import org.apache.commons.math4.exception.util.LocalizedFormats; -import org.apache.commons.math4.random.RandomGenerator; -import org.apache.commons.math4.random.Well19937c; import org.apache.commons.math4.rng.UniformRandomProvider; import org.apache.commons.math4.special.Beta; import org.apache.commons.math4.special.Gamma; @@ -39,7 +37,7 @@ public class BetaDistribution extends AbstractRealDistribution { */ public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9; /** Serializable version identifier. */ - private static final long serialVersionUID = -1221965979403477668L; + private static final long serialVersionUID = 20160311L; /** First shape parameter. */ private final double alpha; /** Second shape parameter. */ @@ -52,14 +50,7 @@ public class BetaDistribution extends AbstractRealDistribution { private final double solverAbsoluteAccuracy; /** - * Build a new instance. - *
- * Note: this constructor will implicitly create an instance of - * {@link Well19937c} as random generator to be used for sampling only (see - * {@link #sample()} and {@link #sample(int)}). In case no sampling is - * needed for the created distribution, it is advised to pass {@code null} - * as random generator via the appropriate constructors to avoid the - * additional initialisation overhead. + * Creates a new instance. * * @param alpha First shape parameter (must be positive). * @param beta Second shape parameter (must be positive). @@ -69,57 +60,19 @@ public class BetaDistribution extends AbstractRealDistribution { } /** - * Build a new instance. - *
- * Note: this constructor will implicitly create an instance of - * {@link Well19937c} as random generator to be used for sampling only (see - * {@link #sample()} and {@link #sample(int)}). In case no sampling is - * needed for the created distribution, it is advised to pass {@code null} - * as random generator via the appropriate constructors to avoid the - * additional initialisation overhead. + * Creates a new instance. * * @param alpha First shape parameter (must be positive). * @param beta Second shape parameter (must be positive). * @param inverseCumAccuracy Maximum absolute error in inverse * cumulative probability estimates (defaults to * {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}). - * @since 2.1 - */ - public BetaDistribution(double alpha, double beta, double inverseCumAccuracy) { - this(new Well19937c(), alpha, beta, inverseCumAccuracy); - } - - /** - * Creates a β distribution. * - * @param rng Random number generator. - * @param alpha First shape parameter (must be positive). - * @param beta Second shape parameter (must be positive). - * @since 3.3 - */ - @Deprecated - public BetaDistribution(RandomGenerator rng, double alpha, double beta) { - this(rng, alpha, beta, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); - } - - /** - * Creates a β distribution. - * - * @param rng Random number generator. - * @param alpha First shape parameter (must be positive). - * @param beta Second shape parameter (must be positive). - * @param inverseCumAccuracy Maximum absolute error in inverse - * cumulative probability estimates (defaults to - * {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}). * @since 3.1 */ - @Deprecated - public BetaDistribution(RandomGenerator rng, - double alpha, + public BetaDistribution(double alpha, double beta, double inverseCumAccuracy) { - super(rng); - this.alpha = alpha; this.beta = beta; z = Double.NaN; diff --git a/src/main/java/org/apache/commons/math4/distribution/CauchyDistribution.java b/src/main/java/org/apache/commons/math4/distribution/CauchyDistribution.java index 39870fb68..a16cf22a0 100644 --- a/src/main/java/org/apache/commons/math4/distribution/CauchyDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/CauchyDistribution.java @@ -19,8 +19,6 @@ package org.apache.commons.math4.distribution; import org.apache.commons.math4.exception.NotStrictlyPositiveException; import org.apache.commons.math4.exception.OutOfRangeException; import org.apache.commons.math4.exception.util.LocalizedFormats; -import org.apache.commons.math4.random.RandomGenerator; -import org.apache.commons.math4.random.Well19937c; import org.apache.commons.math4.util.FastMath; /** @@ -37,7 +35,7 @@ public class CauchyDistribution extends AbstractRealDistribution { */ public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9; /** Serializable version identifier */ - private static final long serialVersionUID = 8589540077390120676L; + private static final long serialVersionUID = 20160311L; /** The median of this distribution. */ private final double median; /** The scale of this distribution. */ @@ -54,31 +52,19 @@ public class CauchyDistribution extends AbstractRealDistribution { } /** - * Creates a Cauchy distribution using the given median and scale. - *
- * Note: this constructor will implicitly create an instance of - * {@link Well19937c} as random generator to be used for sampling only (see - * {@link #sample()} and {@link #sample(int)}). In case no sampling is - * needed for the created distribution, it is advised to pass {@code null} - * as random generator via the appropriate constructors to avoid the - * additional initialisation overhead. + * Creates a distribution. * * @param median Median for this distribution. * @param scale Scale parameter for this distribution. + * @throws NotStrictlyPositiveException if {@code scale <= 0}. */ - public CauchyDistribution(double median, double scale) { + public CauchyDistribution(double median, + double scale) { this(median, scale, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); } /** - * Creates a Cauchy distribution using the given median and scale. - *
- * Note: this constructor will implicitly create an instance of - * {@link Well19937c} as random generator to be used for sampling only (see - * {@link #sample()} and {@link #sample(int)}). In case no sampling is - * needed for the created distribution, it is advised to pass {@code null} - * as random generator via the appropriate constructors to avoid the - * additional initialisation overhead. + * Creates a distribution. * * @param median Median for this distribution. * @param scale Scale parameter for this distribution. @@ -86,43 +72,10 @@ public class CauchyDistribution extends AbstractRealDistribution { * cumulative probability estimates * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}). * @throws NotStrictlyPositiveException if {@code scale <= 0}. - * @since 2.1 */ - public CauchyDistribution(double median, double scale, - double inverseCumAccuracy) { - this(new Well19937c(), median, scale, inverseCumAccuracy); - } - - /** - * Creates a Cauchy distribution. - * - * @param rng Random number generator. - * @param median Median for this distribution. - * @param scale Scale parameter for this distribution. - * @throws NotStrictlyPositiveException if {@code scale <= 0}. - * @since 3.3 - */ - public CauchyDistribution(RandomGenerator rng, double median, double scale) { - this(rng, median, scale, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); - } - - /** - * Creates a Cauchy distribution. - * - * @param rng Random number generator. - * @param median Median for this distribution. - * @param scale Scale parameter for this distribution. - * @param inverseCumAccuracy Maximum absolute error in inverse - * cumulative probability estimates - * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}). - * @throws NotStrictlyPositiveException if {@code scale <= 0}. - * @since 3.1 - */ - public CauchyDistribution(RandomGenerator rng, - double median, + public CauchyDistribution(double median, double scale, double inverseCumAccuracy) { - super(rng); if (scale <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.SCALE, scale); } diff --git a/src/main/java/org/apache/commons/math4/distribution/ChiSquaredDistribution.java b/src/main/java/org/apache/commons/math4/distribution/ChiSquaredDistribution.java index b91754bbb..afd35c0bf 100644 --- a/src/main/java/org/apache/commons/math4/distribution/ChiSquaredDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/ChiSquaredDistribution.java @@ -16,9 +16,6 @@ */ package org.apache.commons.math4.distribution; -import org.apache.commons.math4.random.RandomGenerator; -import org.apache.commons.math4.random.Well19937c; - /** * Implementation of the chi-squared distribution. * @@ -32,14 +29,14 @@ public class ChiSquaredDistribution extends AbstractRealDistribution { */ public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9; /** Serializable version identifier */ - private static final long serialVersionUID = -8352658048349159782L; + private static final long serialVersionUID = 20160311L; /** Internal Gamma distribution. */ private final GammaDistribution gamma; /** Inverse cumulative probability accuracy */ private final double solverAbsoluteAccuracy; /** - * Create a Chi-Squared distribution with the given degrees of freedom. + * Creates distribution with the given degrees of freedom. * * @param degreesOfFreedom Degrees of freedom. */ @@ -48,54 +45,18 @@ public class ChiSquaredDistribution extends AbstractRealDistribution { } /** - * Create a Chi-Squared distribution with the given degrees of freedom and + * Creates a distribution with the given degrees of freedom and * inverse cumulative probability accuracy. - *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
*
* @param degreesOfFreedom Degrees of freedom.
* @param inverseCumAccuracy the maximum absolute error in inverse
* cumulative probability estimates (defaults to
* {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
+ *
* @since 2.1
*/
public ChiSquaredDistribution(double degreesOfFreedom,
double inverseCumAccuracy) {
- this(new Well19937c(), degreesOfFreedom, inverseCumAccuracy);
- }
-
- /**
- * Create a Chi-Squared distribution with the given degrees of freedom.
- *
- * @param rng Random number generator.
- * @param degreesOfFreedom Degrees of freedom.
- * @since 3.3
- */
- public ChiSquaredDistribution(RandomGenerator rng, double degreesOfFreedom) {
- this(rng, degreesOfFreedom, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
- }
-
- /**
- * Create a Chi-Squared distribution with the given degrees of freedom and
- * inverse cumulative probability accuracy.
- *
- * @param rng Random number generator.
- * @param degreesOfFreedom Degrees of freedom.
- * @param inverseCumAccuracy the maximum absolute error in inverse
- * cumulative probability estimates (defaults to
- * {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
- * @since 3.1
- */
- public ChiSquaredDistribution(RandomGenerator rng,
- double degreesOfFreedom,
- double inverseCumAccuracy) {
- super(rng);
-
gamma = new GammaDistribution(degreesOfFreedom / 2, 2);
solverAbsoluteAccuracy = inverseCumAccuracy;
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/ConstantRealDistribution.java b/src/main/java/org/apache/commons/math4/distribution/ConstantRealDistribution.java
index 862fe7551..a9b3383bc 100644
--- a/src/main/java/org/apache/commons/math4/distribution/ConstantRealDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/ConstantRealDistribution.java
@@ -39,7 +39,6 @@ public class ConstantRealDistribution extends AbstractRealDistribution {
* @param value the constant value of this distribution
*/
public ConstantRealDistribution(double value) {
- super(null); // Avoid creating RandomGenerator
this.value = value;
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java b/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java
index 40af6e4d0..fd339b271 100644
--- a/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java
@@ -30,7 +30,6 @@ import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.NullArgumentException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.rng.UniformRandomProvider;
import org.apache.commons.math4.util.MathArrays;
import org.apache.commons.math4.util.Pair;
@@ -61,7 +60,7 @@ public class EnumeratedDistribution
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
- *
- * @param pmf probability mass function enumerated as a list of Implementation of a real-valued {@link EnumeratedDistribution}.
*
* Values with zero-probability are allowed but they do not extend the
- * support.
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
- *
- * @param singletons array of random variable values.
- * @param probabilities array of probabilities.
- * @throws DimensionMismatchException if
- * {@code singletons.length != probabilities.length}
- * @throws NotPositiveException if any of the probabilities are negative.
- * @throws NotFiniteNumberException if any of the probabilities are infinite.
- * @throws NotANumberException if any of the probabilities are NaN.
- * @throws MathArithmeticException all of the probabilities are 0.
- */
- public EnumeratedRealDistribution(final double[] singletons, final double[] probabilities)
- throws DimensionMismatchException, NotPositiveException, MathArithmeticException,
- NotFiniteNumberException, NotANumberException {
- this(new Well19937c(), singletons, probabilities);
- }
-
/**
* Create a discrete real-valued distribution using the given random number generator
* and probability mass function enumeration.
*
- * @param rng random number generator.
* @param singletons array of random variable values.
* @param probabilities array of probabilities.
* @throws DimensionMismatchException if
@@ -94,28 +65,23 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution {
* @throws NotANumberException if any of the probabilities are NaN.
* @throws MathArithmeticException all of the probabilities are 0.
*/
- @Deprecated
- public EnumeratedRealDistribution(final RandomGenerator rng,
- final double[] singletons, final double[] probabilities)
- throws DimensionMismatchException, NotPositiveException, MathArithmeticException,
- NotFiniteNumberException, NotANumberException {
- super(rng);
-
- innerDistribution = new EnumeratedDistribution
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param mean mean of this distribution.
*/
@@ -107,58 +98,19 @@ public class ExponentialDistribution extends AbstractRealDistribution {
}
/**
- * Create an exponential distribution with the given mean.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param mean Mean of this distribution.
* @param inverseCumAccuracy Maximum absolute error in inverse
* cumulative probability estimates (defaults to
* {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
* @throws NotStrictlyPositiveException if {@code mean <= 0}.
+ *
* @since 2.1
*/
- public ExponentialDistribution(double mean, double inverseCumAccuracy) {
- this(new Well19937c(), mean, inverseCumAccuracy);
- }
-
- /**
- * Creates an exponential distribution.
- *
- * @param rng Random number generator.
- * @param mean Mean of this distribution.
- * @throws NotStrictlyPositiveException if {@code mean <= 0}.
- * @since 3.3
- */
- @Deprecated
- public ExponentialDistribution(RandomGenerator rng, double mean)
- throws NotStrictlyPositiveException {
- this(rng, mean, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
- }
-
- /**
- * Creates an exponential distribution.
- *
- * @param rng Random number generator.
- * @param mean Mean of this distribution.
- * @param inverseCumAccuracy Maximum absolute error in inverse
- * cumulative probability estimates (defaults to
- * {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
- * @throws NotStrictlyPositiveException if {@code mean <= 0}.
- * @since 3.1
- */
- @Deprecated
- public ExponentialDistribution(RandomGenerator rng,
- double mean,
+ public ExponentialDistribution(double mean,
double inverseCumAccuracy)
throws NotStrictlyPositiveException {
- super(rng);
-
if (mean <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.MEAN, mean);
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/FDistribution.java b/src/main/java/org/apache/commons/math4/distribution/FDistribution.java
index 907d20187..bcde9aab2 100644
--- a/src/main/java/org/apache/commons/math4/distribution/FDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/FDistribution.java
@@ -19,8 +19,6 @@ package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.special.Beta;
import org.apache.commons.math4.util.FastMath;
@@ -50,14 +48,7 @@ public class FDistribution extends AbstractRealDistribution {
private boolean numericalVarianceIsCalculated = false;
/**
- * Creates an F distribution using the given degrees of freedom.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a using the given degrees of freedom.
*
* @param numeratorDegreesOfFreedom Numerator degrees of freedom.
* @param denominatorDegreesOfFreedom Denominator degrees of freedom.
@@ -73,69 +64,19 @@ public class FDistribution extends AbstractRealDistribution {
}
/**
- * Creates an F distribution using the given degrees of freedom
- * and inverse cumulative probability accuracy.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param numeratorDegreesOfFreedom Numerator degrees of freedom.
* @param denominatorDegreesOfFreedom Denominator degrees of freedom.
* @param inverseCumAccuracy the maximum absolute error in inverse
* cumulative probability estimates.
- * @throws NotStrictlyPositiveException if
- * {@code numeratorDegreesOfFreedom <= 0} or
+ * @throws NotStrictlyPositiveException if {@code numeratorDegreesOfFreedom <= 0} or
* {@code denominatorDegreesOfFreedom <= 0}.
- * @since 2.1
*/
public FDistribution(double numeratorDegreesOfFreedom,
double denominatorDegreesOfFreedom,
double inverseCumAccuracy)
throws NotStrictlyPositiveException {
- this(new Well19937c(), numeratorDegreesOfFreedom,
- denominatorDegreesOfFreedom, inverseCumAccuracy);
- }
-
- /**
- * Creates an F distribution.
- *
- * @param rng Random number generator.
- * @param numeratorDegreesOfFreedom Numerator degrees of freedom.
- * @param denominatorDegreesOfFreedom Denominator degrees of freedom.
- * @throws NotStrictlyPositiveException if {@code numeratorDegreesOfFreedom <= 0} or
- * {@code denominatorDegreesOfFreedom <= 0}.
- * @since 3.3
- */
- public FDistribution(RandomGenerator rng,
- double numeratorDegreesOfFreedom,
- double denominatorDegreesOfFreedom)
- throws NotStrictlyPositiveException {
- this(rng, numeratorDegreesOfFreedom, denominatorDegreesOfFreedom, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
- }
-
- /**
- * Creates an F distribution.
- *
- * @param rng Random number generator.
- * @param numeratorDegreesOfFreedom Numerator degrees of freedom.
- * @param denominatorDegreesOfFreedom Denominator degrees of freedom.
- * @param inverseCumAccuracy the maximum absolute error in inverse
- * cumulative probability estimates.
- * @throws NotStrictlyPositiveException if {@code numeratorDegreesOfFreedom <= 0} or
- * {@code denominatorDegreesOfFreedom <= 0}.
- * @since 3.1
- */
- public FDistribution(RandomGenerator rng,
- double numeratorDegreesOfFreedom,
- double denominatorDegreesOfFreedom,
- double inverseCumAccuracy)
- throws NotStrictlyPositiveException {
- super(rng);
-
if (numeratorDegreesOfFreedom <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.DEGREES_OF_FREEDOM,
numeratorDegreesOfFreedom);
diff --git a/src/main/java/org/apache/commons/math4/distribution/GammaDistribution.java b/src/main/java/org/apache/commons/math4/distribution/GammaDistribution.java
index 2377df79b..c50c9742a 100644
--- a/src/main/java/org/apache/commons/math4/distribution/GammaDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/GammaDistribution.java
@@ -18,8 +18,6 @@ package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.rng.UniformRandomProvider;
import org.apache.commons.math4.special.Gamma;
import org.apache.commons.math4.util.FastMath;
@@ -37,7 +35,7 @@ public class GammaDistribution extends AbstractRealDistribution {
*/
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
/** Serializable version identifier. */
- private static final long serialVersionUID = 20120524L;
+ private static final long serialVersionUID = 20160311L;
/** The shape parameter. */
private final double shape;
/** The scale parameter. */
@@ -99,35 +97,20 @@ public class GammaDistribution extends AbstractRealDistribution {
private final double solverAbsoluteAccuracy;
/**
- * Creates a new gamma distribution with specified values of the shape and
- * scale parameters.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param shape the shape parameter
* @param scale the scale parameter
* @throws NotStrictlyPositiveException if {@code shape <= 0} or
* {@code scale <= 0}.
*/
- public GammaDistribution(double shape, double scale) throws NotStrictlyPositiveException {
+ public GammaDistribution(double shape, double scale)
+ throws NotStrictlyPositiveException {
this(shape, scale, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
}
/**
- * Creates a new gamma distribution with specified values of the shape and
- * scale parameters.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param shape the shape parameter
* @param scale the scale parameter
@@ -136,50 +119,11 @@ public class GammaDistribution extends AbstractRealDistribution {
* {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
* @throws NotStrictlyPositiveException if {@code shape <= 0} or
* {@code scale <= 0}.
- * @since 2.1
*/
- public GammaDistribution(double shape, double scale, double inverseCumAccuracy)
- throws NotStrictlyPositiveException {
- this(new Well19937c(), shape, scale, inverseCumAccuracy);
- }
-
- /**
- * Creates a Gamma distribution.
- *
- * @param rng Random number generator.
- * @param shape the shape parameter
- * @param scale the scale parameter
- * @throws NotStrictlyPositiveException if {@code shape <= 0} or
- * {@code scale <= 0}.
- * @since 3.3
- */
- @Deprecated
- public GammaDistribution(RandomGenerator rng, double shape, double scale)
- throws NotStrictlyPositiveException {
- this(rng, shape, scale, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
- }
-
- /**
- * Creates a Gamma distribution.
- *
- * @param rng Random number generator.
- * @param shape the shape parameter
- * @param scale the scale parameter
- * @param inverseCumAccuracy the maximum absolute error in inverse
- * cumulative probability estimates (defaults to
- * {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
- * @throws NotStrictlyPositiveException if {@code shape <= 0} or
- * {@code scale <= 0}.
- * @since 3.1
- */
- @Deprecated
- public GammaDistribution(RandomGenerator rng,
- double shape,
+ public GammaDistribution(double shape,
double scale,
double inverseCumAccuracy)
throws NotStrictlyPositiveException {
- super(rng);
-
if (shape <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.SHAPE, shape);
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/GumbelDistribution.java b/src/main/java/org/apache/commons/math4/distribution/GumbelDistribution.java
index 0aa3fb238..be06d09ac 100644
--- a/src/main/java/org/apache/commons/math4/distribution/GumbelDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/GumbelDistribution.java
@@ -19,8 +19,6 @@ package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.OutOfRangeException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathUtils;
@@ -35,7 +33,7 @@ import org.apache.commons.math4.util.MathUtils;
public class GumbelDistribution extends AbstractRealDistribution {
/** Serializable version identifier. */
- private static final long serialVersionUID = 20141003;
+ private static final long serialVersionUID = 20160311L;
/**
* Approximation of Euler's constant
@@ -49,34 +47,13 @@ public class GumbelDistribution extends AbstractRealDistribution {
private final double beta;
/**
- * Build a new instance.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param mu location parameter
* @param beta scale parameter (must be positive)
* @throws NotStrictlyPositiveException if {@code beta <= 0}
*/
public GumbelDistribution(double mu, double beta) {
- this(new Well19937c(), mu, beta);
- }
-
- /**
- * Build a new instance.
- *
- * @param rng Random number generator
- * @param mu location parameter
- * @param beta scale parameter (must be positive)
- * @throws NotStrictlyPositiveException if {@code beta <= 0}
- */
- public GumbelDistribution(RandomGenerator rng, double mu, double beta) {
- super(rng);
-
if (beta <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.SCALE, beta);
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/LaplaceDistribution.java b/src/main/java/org/apache/commons/math4/distribution/LaplaceDistribution.java
index 7e41a29a7..c85618ba4 100644
--- a/src/main/java/org/apache/commons/math4/distribution/LaplaceDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/LaplaceDistribution.java
@@ -19,8 +19,6 @@ package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.OutOfRangeException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.util.FastMath;
/**
@@ -33,7 +31,7 @@ import org.apache.commons.math4.util.FastMath;
public class LaplaceDistribution extends AbstractRealDistribution {
/** Serializable version identifier. */
- private static final long serialVersionUID = 20141003;
+ private static final long serialVersionUID = 20160311L;
/** The location parameter. */
private final double mu;
@@ -41,34 +39,13 @@ public class LaplaceDistribution extends AbstractRealDistribution {
private final double beta;
/**
- * Build a new instance.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param mu location parameter
* @param beta scale parameter (must be positive)
* @throws NotStrictlyPositiveException if {@code beta <= 0}
*/
public LaplaceDistribution(double mu, double beta) {
- this(new Well19937c(), mu, beta);
- }
-
- /**
- * Build a new instance.
- *
- * @param rng Random number generator
- * @param mu location parameter
- * @param beta scale parameter (must be positive)
- * @throws NotStrictlyPositiveException if {@code beta <= 0}
- */
- public LaplaceDistribution(RandomGenerator rng, double mu, double beta) {
- super(rng);
-
if (beta <= 0.0) {
throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_SCALE, beta);
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/LevyDistribution.java b/src/main/java/org/apache/commons/math4/distribution/LevyDistribution.java
index 5f55c83dd..a8d579367 100644
--- a/src/main/java/org/apache/commons/math4/distribution/LevyDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/LevyDistribution.java
@@ -17,8 +17,6 @@
package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.OutOfRangeException;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.special.Erf;
import org.apache.commons.math4.util.FastMath;
@@ -31,7 +29,7 @@ import org.apache.commons.math4.util.FastMath;
public class LevyDistribution extends AbstractRealDistribution {
/** Serializable UID. */
- private static final long serialVersionUID = 20130314L;
+ private static final long serialVersionUID = 20630311L;
/** Location parameter. */
private final double mu;
@@ -43,33 +41,14 @@ public class LevyDistribution extends AbstractRealDistribution {
private final double halfC;
/**
- * Build a new instance.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
- * @param mu location parameter
- * @param c scale parameter
- * @since 3.4
- */
- public LevyDistribution(final double mu, final double c) {
- this(new Well19937c(), mu, c);
- }
-
- /**
- * Creates a LevyDistribution.
- * @param rng random generator to be used for sampling
* @param mu location
* @param c scale parameter
*/
- public LevyDistribution(final RandomGenerator rng, final double mu, final double c) {
- super(rng);
- this.mu = mu;
- this.c = c;
+ public LevyDistribution(final double mu, final double c) {
+ this.mu = mu;
+ this.c = c;
this.halfC = 0.5 * c;
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/LogNormalDistribution.java b/src/main/java/org/apache/commons/math4/distribution/LogNormalDistribution.java
index 8bec045e4..eafb90e8f 100644
--- a/src/main/java/org/apache/commons/math4/distribution/LogNormalDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/LogNormalDistribution.java
@@ -20,8 +20,6 @@ package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.NumberIsTooLargeException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.rng.UniformRandomProvider;
import org.apache.commons.math4.special.Erf;
import org.apache.commons.math4.util.FastMath;
@@ -78,35 +76,21 @@ public class LogNormalDistribution extends AbstractRealDistribution {
private final double solverAbsoluteAccuracy;
/**
- * Create a log-normal distribution, where the mean and standard deviation
+ * Creates a log-normal distribution, where the mean and standard deviation
* of the {@link NormalDistribution normally distributed} natural
* logarithm of the log-normal distribution are equal to zero and one
* respectively. In other words, the scale of the returned distribution is
* {@code 0}, while its shape is {@code 1}.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
*/
public LogNormalDistribution() {
this(0, 1);
}
/**
- * Create a log-normal distribution using the specified scale and shape.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a log-normal distribution.
*
- * @param scale the scale parameter of this distribution
- * @param shape the shape parameter of this distribution
+ * @param scale Scale parameter of this distribution.
+ * @param shape Shape parameter of this distribution.
* @throws NotStrictlyPositiveException if {@code shape <= 0}.
*/
public LogNormalDistribution(double scale, double shape)
@@ -114,60 +98,18 @@ public class LogNormalDistribution extends AbstractRealDistribution {
this(scale, shape, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
}
- /**
- * Create a log-normal distribution using the specified scale, shape and
- * inverse cumulative distribution accuracy.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
- *
- * @param scale the scale parameter of this distribution
- * @param shape the shape parameter of this distribution
- * @param inverseCumAccuracy Inverse cumulative probability accuracy.
- * @throws NotStrictlyPositiveException if {@code shape <= 0}.
- */
- public LogNormalDistribution(double scale, double shape, double inverseCumAccuracy)
- throws NotStrictlyPositiveException {
- this(new Well19937c(), scale, shape, inverseCumAccuracy);
- }
-
/**
* Creates a log-normal distribution.
*
- * @param rng Random number generator.
- * @param scale Scale parameter of this distribution.
- * @param shape Shape parameter of this distribution.
- * @throws NotStrictlyPositiveException if {@code shape <= 0}.
- * @since 3.3
- */
- @Deprecated
- public LogNormalDistribution(RandomGenerator rng, double scale, double shape)
- throws NotStrictlyPositiveException {
- this(rng, scale, shape, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
- }
-
- /**
- * Creates a log-normal distribution.
- *
- * @param rng Random number generator.
* @param scale Scale parameter of this distribution.
* @param shape Shape parameter of this distribution.
* @param inverseCumAccuracy Inverse cumulative probability accuracy.
* @throws NotStrictlyPositiveException if {@code shape <= 0}.
- * @since 3.1
*/
- @Deprecated
- public LogNormalDistribution(RandomGenerator rng,
- double scale,
+ public LogNormalDistribution(double scale,
double shape,
double inverseCumAccuracy)
throws NotStrictlyPositiveException {
- super(rng);
-
if (shape <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.SHAPE, shape);
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/LogisticDistribution.java b/src/main/java/org/apache/commons/math4/distribution/LogisticDistribution.java
index 14c2a9887..1c69804bd 100644
--- a/src/main/java/org/apache/commons/math4/distribution/LogisticDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/LogisticDistribution.java
@@ -19,8 +19,6 @@ package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.OutOfRangeException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathUtils;
@@ -35,7 +33,7 @@ import org.apache.commons.math4.util.MathUtils;
public class LogisticDistribution extends AbstractRealDistribution {
/** Serializable version identifier. */
- private static final long serialVersionUID = 20141003;
+ private static final long serialVersionUID = 20160311L;
/** The location parameter. */
private final double mu;
@@ -43,34 +41,14 @@ public class LogisticDistribution extends AbstractRealDistribution {
private final double s;
/**
- * Build a new instance.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param mu location parameter
* @param s scale parameter (must be positive)
* @throws NotStrictlyPositiveException if {@code beta <= 0}
*/
- public LogisticDistribution(double mu, double s) {
- this(new Well19937c(), mu, s);
- }
-
- /**
- * Build a new instance.
- *
- * @param rng Random number generator
- * @param mu location parameter
- * @param s scale parameter (must be positive)
- * @throws NotStrictlyPositiveException if {@code beta <= 0}
- */
- public LogisticDistribution(RandomGenerator rng, double mu, double s) {
- super(rng);
-
+ public LogisticDistribution(double mu,
+ double s) {
if (s <= 0.0) {
throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_SCALE, s);
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/NakagamiDistribution.java b/src/main/java/org/apache/commons/math4/distribution/NakagamiDistribution.java
index fa8b0f5bc..5f7e405a1 100644
--- a/src/main/java/org/apache/commons/math4/distribution/NakagamiDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/NakagamiDistribution.java
@@ -19,8 +19,6 @@ package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.NumberIsTooSmallException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.special.Gamma;
import org.apache.commons.math4.util.FastMath;
@@ -37,7 +35,7 @@ public class NakagamiDistribution extends AbstractRealDistribution {
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
/** Serializable version identifier. */
- private static final long serialVersionUID = 20141003;
+ private static final long serialVersionUID = 20160311L;
/** The shape parameter. */
private final double mu;
@@ -47,33 +45,20 @@ public class NakagamiDistribution extends AbstractRealDistribution {
private final double inverseAbsoluteAccuracy;
/**
- * Build a new instance.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param mu shape parameter
* @param omega scale parameter (must be positive)
* @throws NumberIsTooSmallException if {@code mu < 0.5}
* @throws NotStrictlyPositiveException if {@code omega <= 0}
*/
- public NakagamiDistribution(double mu, double omega) {
+ public NakagamiDistribution(double mu,
+ double omega) {
this(mu, omega, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
}
/**
- * Build a new instance.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param mu shape parameter
* @param omega scale parameter (must be positive)
@@ -82,24 +67,9 @@ public class NakagamiDistribution extends AbstractRealDistribution {
* @throws NumberIsTooSmallException if {@code mu < 0.5}
* @throws NotStrictlyPositiveException if {@code omega <= 0}
*/
- public NakagamiDistribution(double mu, double omega, double inverseAbsoluteAccuracy) {
- this(new Well19937c(), mu, omega, inverseAbsoluteAccuracy);
- }
-
- /**
- * Build a new instance.
- *
- * @param rng Random number generator
- * @param mu shape parameter
- * @param omega scale parameter (must be positive)
- * @param inverseAbsoluteAccuracy the maximum absolute error in inverse
- * cumulative probability estimates (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
- * @throws NumberIsTooSmallException if {@code mu < 0.5}
- * @throws NotStrictlyPositiveException if {@code omega <= 0}
- */
- public NakagamiDistribution(RandomGenerator rng, double mu, double omega, double inverseAbsoluteAccuracy) {
- super(rng);
-
+ public NakagamiDistribution(double mu,
+ double omega,
+ double inverseAbsoluteAccuracy) {
if (mu < 0.5) {
throw new NumberIsTooSmallException(mu, 0.5, true);
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java b/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java
index 01de515c2..a8330d5e7 100644
--- a/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java
@@ -21,8 +21,6 @@ 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.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.rng.UniformRandomProvider;
import org.apache.commons.math4.special.Erf;
import org.apache.commons.math4.util.FastMath;
@@ -55,92 +53,37 @@ public class NormalDistribution extends AbstractRealDistribution {
/**
* Create a normal distribution with mean equal to zero and standard
* deviation equal to one.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
*/
public NormalDistribution() {
this(0, 1);
}
/**
- * Create a normal distribution using the given mean and standard deviation.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param mean Mean for this distribution.
* @param sd Standard deviation for this distribution.
* @throws NotStrictlyPositiveException if {@code sd <= 0}.
*/
- public NormalDistribution(double mean, double sd)
+ public NormalDistribution(double mean,
+ double sd)
throws NotStrictlyPositiveException {
this(mean, sd, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
}
+
/**
- * Create a normal distribution using the given mean, standard deviation and
- * inverse cumulative distribution accuracy.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param mean Mean for this distribution.
* @param sd Standard deviation for this distribution.
* @param inverseCumAccuracy Inverse cumulative probability accuracy.
* @throws NotStrictlyPositiveException if {@code sd <= 0}.
- * @since 2.1
*/
- public NormalDistribution(double mean, double sd, double inverseCumAccuracy)
- throws NotStrictlyPositiveException {
- this(new Well19937c(), mean, sd, inverseCumAccuracy);
- }
-
- /**
- * Creates a normal distribution.
- *
- * @param rng Random number generator.
- * @param mean Mean for this distribution.
- * @param sd Standard deviation for this distribution.
- * @throws NotStrictlyPositiveException if {@code sd <= 0}.
- * @since 3.3
- */
- @Deprecated
- public NormalDistribution(RandomGenerator rng, double mean, double sd)
- throws NotStrictlyPositiveException {
- this(rng, mean, sd, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
- }
-
- /**
- * Creates a normal distribution.
- *
- * @param rng Random number generator.
- * @param mean Mean for this distribution.
- * @param sd Standard deviation for this distribution.
- * @param inverseCumAccuracy Inverse cumulative probability accuracy.
- * @throws NotStrictlyPositiveException if {@code sd <= 0}.
- * @since 3.1
- */
- @Deprecated
- public NormalDistribution(RandomGenerator rng,
- double mean,
+ public NormalDistribution(double mean,
double sd,
double inverseCumAccuracy)
throws NotStrictlyPositiveException {
- super(rng);
-
if (sd <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sd);
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/ParetoDistribution.java b/src/main/java/org/apache/commons/math4/distribution/ParetoDistribution.java
index bd074faa5..217432231 100644
--- a/src/main/java/org/apache/commons/math4/distribution/ParetoDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/ParetoDistribution.java
@@ -19,8 +19,6 @@ package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.rng.UniformRandomProvider;
import org.apache.commons.math4.util.FastMath;
@@ -52,7 +50,7 @@ public class ParetoDistribution extends AbstractRealDistribution {
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
/** Serializable version identifier. */
- private static final long serialVersionUID = 20130424;
+ private static final long serialVersionUID = 20160311L;
/** The scale parameter of this distribution. */
private final double scale;
@@ -64,83 +62,37 @@ public class ParetoDistribution extends AbstractRealDistribution {
private final double solverAbsoluteAccuracy;
/**
- * Create a Pareto distribution with a scale of {@code 1} and a shape of {@code 1}.
+ * Creates a Pareto distribution with a scale of {@code 1} and a shape of {@code 1}.
*/
public ParetoDistribution() {
this(1, 1);
}
/**
- * Create a Pareto distribution using the specified scale and shape.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a Pareto distribution.
*
* @param scale the scale parameter of this distribution
* @param shape the shape parameter of this distribution
* @throws NotStrictlyPositiveException if {@code scale <= 0} or {@code shape <= 0}.
*/
- public ParetoDistribution(double scale, double shape)
+ public ParetoDistribution(double scale,
+ double shape)
throws NotStrictlyPositiveException {
this(scale, shape, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
}
- /**
- * Create a Pareto distribution using the specified scale, shape and
- * inverse cumulative distribution accuracy.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
- *
- * @param scale the scale parameter of this distribution
- * @param shape the shape parameter of this distribution
- * @param inverseCumAccuracy Inverse cumulative probability accuracy.
- * @throws NotStrictlyPositiveException if {@code scale <= 0} or {@code shape <= 0}.
- */
- public ParetoDistribution(double scale, double shape, double inverseCumAccuracy)
- throws NotStrictlyPositiveException {
- this(new Well19937c(), scale, shape, inverseCumAccuracy);
- }
-
/**
* Creates a Pareto distribution.
*
- * @param rng Random number generator.
- * @param scale Scale parameter of this distribution.
- * @param shape Shape parameter of this distribution.
- * @throws NotStrictlyPositiveException if {@code scale <= 0} or {@code shape <= 0}.
- */
- @Deprecated
- public ParetoDistribution(RandomGenerator rng, double scale, double shape)
- throws NotStrictlyPositiveException {
- this(rng, scale, shape, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
- }
-
- /**
- * Creates a Pareto distribution.
- *
- * @param rng Random number generator.
* @param scale Scale parameter of this distribution.
* @param shape Shape parameter of this distribution.
* @param inverseCumAccuracy Inverse cumulative probability accuracy.
* @throws NotStrictlyPositiveException if {@code scale <= 0} or {@code shape <= 0}.
*/
- @Deprecated
- public ParetoDistribution(RandomGenerator rng,
- double scale,
+ public ParetoDistribution(double scale,
double shape,
double inverseCumAccuracy)
throws NotStrictlyPositiveException {
- super(rng);
-
if (scale <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.SCALE, scale);
}
diff --git a/src/main/java/org/apache/commons/math4/distribution/PoissonDistribution.java b/src/main/java/org/apache/commons/math4/distribution/PoissonDistribution.java
index 731a6ac37..6cb0129c0 100644
--- a/src/main/java/org/apache/commons/math4/distribution/PoissonDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/PoissonDistribution.java
@@ -24,6 +24,7 @@ import org.apache.commons.math4.special.Gamma;
import org.apache.commons.math4.util.CombinatoricsUtils;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathUtils;
+import org.apache.commons.math4.rng.RandomSource;
/**
* Implementation of the Poisson distribution.
@@ -47,7 +48,7 @@ public class PoissonDistribution extends AbstractIntegerDistribution {
/** Distribution used to compute normal approximation. */
private final NormalDistribution normal;
/** Distribution needed for the {@link #sample()} method. */
- private final ExponentialDistribution exponential;
+ private final RealDistribution.Sampler exponentialSampler;
/** Mean of the distribution. */
private final double mean;
@@ -130,10 +131,11 @@ public class PoissonDistribution extends AbstractIntegerDistribution {
this.maxIterations = maxIterations;
// Use the same RNG instance as the parent class.
- normal = new NormalDistribution(rng, p, FastMath.sqrt(p),
+ normal = new NormalDistribution(p, FastMath.sqrt(p),
NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
- exponential = new ExponentialDistribution(rng, 1,
- ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
+
+ // XXX TODO: RNG source should not be hard-coded.
+ exponentialSampler = new ExponentialDistribution(1).createSampler(RandomSource.create(RandomSource.WELL_19937_C));
}
/**
@@ -364,16 +366,16 @@ public class PoissonDistribution extends AbstractIntegerDistribution {
continue;
}
y = x < 0 ? FastMath.floor(x) : FastMath.ceil(x);
- final double e = exponential.sample();
+ final double e = exponentialSampler.sample();
v = -e - (n * n / 2) + c1;
} else {
if (u > p1 + p2) {
y = lambda;
break;
} else {
- x = delta + (twolpd / delta) * exponential.sample();
+ x = delta + (twolpd / delta) * exponentialSampler.sample();
y = FastMath.ceil(x);
- v = -exponential.sample() - delta * (x + 1) / twolpd;
+ v = -exponentialSampler.sample() - delta * (x + 1) / twolpd;
}
}
a = x < 0 ? 1 : 0;
diff --git a/src/main/java/org/apache/commons/math4/distribution/TDistribution.java b/src/main/java/org/apache/commons/math4/distribution/TDistribution.java
index 302d47610..e51055626 100644
--- a/src/main/java/org/apache/commons/math4/distribution/TDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/TDistribution.java
@@ -18,8 +18,6 @@ package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.special.Beta;
import org.apache.commons.math4.special.Gamma;
import org.apache.commons.math4.util.FastMath;
@@ -37,7 +35,7 @@ public class TDistribution extends AbstractRealDistribution {
*/
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
/** Serializable version identifier */
- private static final long serialVersionUID = -5852615386664158222L;
+ private static final long serialVersionUID = 20160311L;
/** The degrees of freedom. */
private final double degreesOfFreedom;
/** Inverse cumulative probability accuracy. */
@@ -46,14 +44,7 @@ public class TDistribution extends AbstractRealDistribution {
private final double factor;
/**
- * Create a t distribution using the given degrees of freedom.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param degreesOfFreedom Degrees of freedom.
* @throws NotStrictlyPositiveException if {@code degreesOfFreedom <= 0}
@@ -64,58 +55,17 @@ public class TDistribution extends AbstractRealDistribution {
}
/**
- * Create a t distribution using the given degrees of freedom and the
- * specified inverse cumulative probability absolute accuracy.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param degreesOfFreedom Degrees of freedom.
* @param inverseCumAccuracy the maximum absolute error in inverse
* cumulative probability estimates
* (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
* @throws NotStrictlyPositiveException if {@code degreesOfFreedom <= 0}
- * @since 2.1
*/
- public TDistribution(double degreesOfFreedom, double inverseCumAccuracy)
- throws NotStrictlyPositiveException {
- this(new Well19937c(), degreesOfFreedom, inverseCumAccuracy);
- }
-
- /**
- * Creates a t distribution.
- *
- * @param rng Random number generator.
- * @param degreesOfFreedom Degrees of freedom.
- * @throws NotStrictlyPositiveException if {@code degreesOfFreedom <= 0}
- * @since 3.3
- */
- public TDistribution(RandomGenerator rng, double degreesOfFreedom)
- throws NotStrictlyPositiveException {
- this(rng, degreesOfFreedom, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
- }
-
- /**
- * Creates a t distribution.
- *
- * @param rng Random number generator.
- * @param degreesOfFreedom Degrees of freedom.
- * @param inverseCumAccuracy the maximum absolute error in inverse
- * cumulative probability estimates
- * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
- * @throws NotStrictlyPositiveException if {@code degreesOfFreedom <= 0}
- * @since 3.1
- */
- public TDistribution(RandomGenerator rng,
- double degreesOfFreedom,
+ public TDistribution(double degreesOfFreedom,
double inverseCumAccuracy)
throws NotStrictlyPositiveException {
- super(rng);
-
if (degreesOfFreedom <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.DEGREES_OF_FREEDOM,
degreesOfFreedom);
diff --git a/src/main/java/org/apache/commons/math4/distribution/TriangularDistribution.java b/src/main/java/org/apache/commons/math4/distribution/TriangularDistribution.java
index 072f5c571..4013c4769 100644
--- a/src/main/java/org/apache/commons/math4/distribution/TriangularDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/TriangularDistribution.java
@@ -21,8 +21,6 @@ import org.apache.commons.math4.exception.NumberIsTooLargeException;
import org.apache.commons.math4.exception.NumberIsTooSmallException;
import org.apache.commons.math4.exception.OutOfRangeException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.util.FastMath;
/**
@@ -35,7 +33,7 @@ import org.apache.commons.math4.util.FastMath;
*/
public class TriangularDistribution extends AbstractRealDistribution {
/** Serializable version identifier. */
- private static final long serialVersionUID = 20120112L;
+ private static final long serialVersionUID = 20160311L;
/** Lower limit of this distribution (inclusive). */
private final double a;
/** Upper limit of this distribution (inclusive). */
@@ -46,45 +44,20 @@ public class TriangularDistribution extends AbstractRealDistribution {
private final double solverAbsoluteAccuracy;
/**
- * Creates a triangular real distribution using the given lower limit,
- * upper limit, and mode.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param a Lower limit of this distribution (inclusive).
* @param b Upper limit of this distribution (inclusive).
* @param c Mode of this distribution.
* @throws NumberIsTooLargeException if {@code a >= b} or if {@code c > b}.
* @throws NumberIsTooSmallException if {@code c < a}.
- */
- public TriangularDistribution(double a, double c, double b)
- throws NumberIsTooLargeException, NumberIsTooSmallException {
- this(new Well19937c(), a, c, b);
- }
-
- /**
- * Creates a triangular distribution.
- *
- * @param rng Random number generator.
- * @param a Lower limit of this distribution (inclusive).
- * @param b Upper limit of this distribution (inclusive).
- * @param c Mode of this distribution.
- * @throws NumberIsTooLargeException if {@code a >= b} or if {@code c > b}.
- * @throws NumberIsTooSmallException if {@code c < a}.
* @since 3.1
*/
- public TriangularDistribution(RandomGenerator rng,
- double a,
+ public TriangularDistribution(double a,
double c,
double b)
- throws NumberIsTooLargeException, NumberIsTooSmallException {
- super(rng);
-
+ throws NumberIsTooLargeException,
+ NumberIsTooSmallException {
if (a >= b) {
throw new NumberIsTooLargeException(
LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
diff --git a/src/main/java/org/apache/commons/math4/distribution/UniformRealDistribution.java b/src/main/java/org/apache/commons/math4/distribution/UniformRealDistribution.java
index 704aa9765..404cc0286 100644
--- a/src/main/java/org/apache/commons/math4/distribution/UniformRealDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/UniformRealDistribution.java
@@ -20,8 +20,6 @@ package org.apache.commons.math4.distribution;
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.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.rng.UniformRandomProvider;
/**
@@ -34,7 +32,7 @@ import org.apache.commons.math4.rng.UniformRandomProvider;
*/
public class UniformRealDistribution extends AbstractRealDistribution {
/** Serializable version identifier. */
- private static final long serialVersionUID = 20120109L;
+ private static final long serialVersionUID = 20160311L;
/** Lower bound of this distribution (inclusive). */
private final double lower;
/** Upper bound of this distribution (exclusive). */
@@ -43,53 +41,21 @@ public class UniformRealDistribution extends AbstractRealDistribution {
/**
* Create a standard uniform real distribution with lower bound (inclusive)
* equal to zero and upper bound (exclusive) equal to one.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
*/
public UniformRealDistribution() {
this(0, 1);
}
- /**
- * Create a uniform real distribution using the given lower and upper
- * bounds.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
- *
- * @param lower Lower bound of this distribution (inclusive).
- * @param upper Upper bound of this distribution (exclusive).
- * @throws NumberIsTooLargeException if {@code lower >= upper}.
- */
- public UniformRealDistribution(double lower, double upper)
- throws NumberIsTooLargeException {
- this(new Well19937c(), lower, upper);
- }
-
/**
* Creates a uniform distribution.
*
- * @param rng Random number generator.
* @param lower Lower bound of this distribution (inclusive).
* @param upper Upper bound of this distribution (exclusive).
* @throws NumberIsTooLargeException if {@code lower >= upper}.
- * @since 3.1
*/
- @Deprecated
- public UniformRealDistribution(RandomGenerator rng,
- double lower,
+ public UniformRealDistribution(double lower,
double upper)
throws NumberIsTooLargeException {
- super(rng);
if (lower >= upper) {
throw new NumberIsTooLargeException(
LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
@@ -207,7 +173,7 @@ public class UniformRealDistribution extends AbstractRealDistribution {
/** {@inheritDoc} */
@Override
public double sample() {
- final double u = random.nextDouble();
+ final double u = rng.nextDouble();
return u * upper + (1 - u) * lower;
}
};
diff --git a/src/main/java/org/apache/commons/math4/distribution/WeibullDistribution.java b/src/main/java/org/apache/commons/math4/distribution/WeibullDistribution.java
index 893501ee3..844bf4a75 100644
--- a/src/main/java/org/apache/commons/math4/distribution/WeibullDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/WeibullDistribution.java
@@ -20,8 +20,6 @@ package org.apache.commons.math4.distribution;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.OutOfRangeException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.special.Gamma;
import org.apache.commons.math4.util.FastMath;
@@ -33,7 +31,8 @@ import org.apache.commons.math4.util.FastMath;
*
* @see Weibull distribution (Wikipedia)
* @see Weibull distribution (MathWorld)
- * @since 1.1 (changed to concrete class in 3.0)
+ *
+ * @since 1.1
*/
public class WeibullDistribution extends AbstractRealDistribution {
/**
@@ -42,7 +41,7 @@ public class WeibullDistribution extends AbstractRealDistribution {
*/
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
/** Serializable version identifier. */
- private static final long serialVersionUID = 8589540077390120676L;
+ private static final long serialVersionUID = 20160311L;
/** The shape parameter. */
private final double shape;
/** The scale parameter. */
@@ -59,15 +58,7 @@ public class WeibullDistribution extends AbstractRealDistribution {
private boolean numericalVarianceIsCalculated = false;
/**
- * Create a Weibull distribution with the given shape and scale and a
- * location equal to zero.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param alpha Shape parameter.
* @param beta Scale parameter.
@@ -80,63 +71,19 @@ public class WeibullDistribution extends AbstractRealDistribution {
}
/**
- * Create a Weibull distribution with the given shape, scale and inverse
- * cumulative probability accuracy and a location equal to zero.
- *
- * Note: this constructor will implicitly create an instance of
- * {@link Well19937c} as random generator to be used for sampling only (see
- * {@link #sample()} and {@link #sample(int)}). In case no sampling is
- * needed for the created distribution, it is advised to pass {@code null}
- * as random generator via the appropriate constructors to avoid the
- * additional initialisation overhead.
+ * Creates a distribution.
*
* @param alpha Shape parameter.
* @param beta Scale parameter.
* @param inverseCumAccuracy Maximum absolute error in inverse
* cumulative probability estimates
* (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
- * @throws NotStrictlyPositiveException if {@code alpha <= 0} or
- * {@code beta <= 0}.
- * @since 2.1
- */
- public WeibullDistribution(double alpha, double beta,
- double inverseCumAccuracy) {
- this(new Well19937c(), alpha, beta, inverseCumAccuracy);
- }
-
- /**
- * Creates a Weibull distribution.
- *
- * @param rng Random number generator.
- * @param alpha Shape parameter.
- * @param beta Scale parameter.
* @throws NotStrictlyPositiveException if {@code alpha <= 0} or {@code beta <= 0}.
- * @since 3.3
*/
- public WeibullDistribution(RandomGenerator rng, double alpha, double beta)
- throws NotStrictlyPositiveException {
- this(rng, alpha, beta, DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
- }
-
- /**
- * Creates a Weibull distribution.
- *
- * @param rng Random number generator.
- * @param alpha Shape parameter.
- * @param beta Scale parameter.
- * @param inverseCumAccuracy Maximum absolute error in inverse
- * cumulative probability estimates
- * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
- * @throws NotStrictlyPositiveException if {@code alpha <= 0} or {@code beta <= 0}.
- * @since 3.1
- */
- public WeibullDistribution(RandomGenerator rng,
- double alpha,
+ public WeibullDistribution(double alpha,
double beta,
double inverseCumAccuracy)
throws NotStrictlyPositiveException {
- super(rng);
-
if (alpha <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.SHAPE,
alpha);
diff --git a/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java b/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java
index 6d2722e13..926ad093c 100644
--- a/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java
+++ b/src/main/java/org/apache/commons/math4/random/EmpiricalDistribution.java
@@ -41,6 +41,8 @@ import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
import org.apache.commons.math4.stat.descriptive.StatisticalSummary;
import org.apache.commons.math4.stat.descriptive.SummaryStatistics;
+import org.apache.commons.math4.rng.UniformRandomProvider;
+import org.apache.commons.math4.rng.RandomSource;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathUtils;
@@ -112,6 +114,7 @@ public class EmpiricalDistribution extends AbstractRealDistribution {
private static final long serialVersionUID = 5729073523949762654L;
/** RandomDataGenerator instance to use in repeated calls to getNext() */
+ @Deprecated
protected final RandomDataGenerator randomData;
/** List of SummaryStatistics objects characterizing the bins */
@@ -152,8 +155,13 @@ public class EmpiricalDistribution extends AbstractRealDistribution {
* @throws NotStrictlyPositiveException if {@code binCount <= 0}.
*/
public EmpiricalDistribution(int binCount) {
- this(binCount, new RandomDataGenerator());
- }
+ if (binCount <= 0) {
+ throw new NotStrictlyPositiveException(binCount);
+ }
+ this.binCount = binCount;
+ binStats = new ArrayList
+ * support.
* Duplicate values are allowed. Probabilities of duplicate values are combined
* when computing cumulative probabilities and statistics.