MATH-1158 Using the new sampler API. Deprecate old API (including the now obsolete constructors).
Apart from the main focus of the issue (distribution classes), this change also had an impact on: * some of test classes that use random numbers (where the tolerance may have its value updated when it is highly sensitive on the RNG seed) * statistical inference tests that use a distribution but not the RNG (cf. MATH-1124) which now deprecated code passed to its contructor. * classes in package "o.a.c.m.random" that depend on some of the distributions Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/9867d9f2 Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/9867d9f2 Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/9867d9f2 Branch: refs/heads/feature-MATH-1158 Commit: 9867d9f2817fd6dd20d458022de3dda8c3b43b2f Parents: 26d668f Author: Gilles <er...@apache.org> Authored: Wed Mar 16 16:46:51 2016 +0100 Committer: Gilles <er...@apache.org> Committed: Wed Mar 16 16:46:51 2016 +0100 ---------------------------------------------------------------------- .../distribution/AbstractRealDistribution.java | 14 +-- .../math4/distribution/BetaDistribution.java | 55 +-------- .../math4/distribution/CauchyDistribution.java | 61 ++-------- .../distribution/ChiSquaredDistribution.java | 47 +------- .../distribution/ConstantRealDistribution.java | 1 - .../distribution/EnumeratedDistribution.java | 67 ++++++----- .../EnumeratedRealDistribution.java | 73 +++--------- .../distribution/ExponentialDistribution.java | 58 +-------- .../math4/distribution/FDistribution.java | 65 +--------- .../math4/distribution/GammaDistribution.java | 68 +---------- .../math4/distribution/GumbelDistribution.java | 27 +---- .../math4/distribution/LaplaceDistribution.java | 27 +---- .../math4/distribution/LevyDistribution.java | 31 +---- .../distribution/LogNormalDistribution.java | 66 +---------- .../distribution/LogisticDistribution.java | 30 +---- .../distribution/NakagamiDistribution.java | 46 ++------ .../math4/distribution/NormalDistribution.java | 67 +---------- .../math4/distribution/ParetoDistribution.java | 60 +--------- .../math4/distribution/PoissonDistribution.java | 16 +-- .../math4/distribution/TDistribution.java | 58 +-------- .../distribution/TriangularDistribution.java | 37 +----- .../distribution/UniformRealDistribution.java | 40 +------ .../math4/distribution/WeibullDistribution.java | 65 +--------- .../math4/random/EmpiricalDistribution.java | 40 +++++-- .../math4/random/RandomDataGenerator.java | 109 +++++++++++++---- .../commons/math4/random/ValueServer.java | 4 +- .../math4/stat/inference/ChiSquareTest.java | 4 +- .../commons/math4/stat/inference/GTest.java | 6 +- .../stat/inference/KolmogorovSmirnovTest.java | 42 ++++--- .../math4/stat/inference/MannWhitneyUTest.java | 2 +- .../math4/stat/inference/OneWayAnova.java | 4 +- .../commons/math4/stat/inference/TTest.java | 6 +- .../stat/inference/WilcoxonSignedRankTest.java | 2 +- .../AkimaSplineInterpolatorTest.java | 11 +- .../BicubicInterpolatingFunctionTest.java | 11 +- .../interpolation/BicubicInterpolatorTest.java | 11 +- ...eBicubicSplineInterpolatingFunctionTest.java | 13 +- .../PiecewiseBicubicSplineInterpolatorTest.java | 17 +-- .../TricubicInterpolatingFunctionTest.java | 13 +- .../AbstractRealDistributionTest.java | 4 +- .../distribution/BetaDistributionTest.java | 4 +- .../ConstantRealDistributionTest.java | 9 -- .../EnumeratedRealDistributionTest.java | 4 +- .../distribution/LevyDistributionTest.java | 3 +- .../RealDistributionAbstractTest.java | 28 ++--- .../commons/math4/filter/KalmanFilterTest.java | 10 +- .../LevenbergMarquardtOptimizerTest.java | 2 +- .../RandomCirclePointGenerator.java | 20 ++-- .../RandomStraightLinePointGenerator.java | 15 ++- .../math4/random/EmpiricalDistributionTest.java | 118 +++++++++++-------- .../descriptive/rank/PSquarePercentileTest.java | 7 +- .../stat/descriptive/rank/PercentileTest.java | 27 +++-- .../inference/KolmogorovSmirnovTestTest.java | 33 +++--- 53 files changed, 490 insertions(+), 1168 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java ---------------------------------------------------------------------- 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 f584253..1f6c006 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 http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/BetaDistribution.java ---------------------------------------------------------------------- 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 3009abf..0644eb1 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. - * <p> - * <b>Note:</b> 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. - * <p> - * <b>Note:</b> 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; http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/CauchyDistribution.java ---------------------------------------------------------------------- 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 39870fb..a16cf22 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,75 +52,30 @@ public class CauchyDistribution extends AbstractRealDistribution { } /** - * Creates a Cauchy distribution using the given median and scale. - * <p> - * <b>Note:</b> 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. - */ - public CauchyDistribution(double median, double scale) { - this(median, scale, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); - } - - /** - * Creates a Cauchy distribution using the given median and scale. - * <p> - * <b>Note:</b> 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 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 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); + public CauchyDistribution(double median, + double scale) { + this(median, scale, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); } /** - * Creates a Cauchy distribution. + * Creates a 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); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/ChiSquaredDistribution.java ---------------------------------------------------------------------- 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 b91754b..afd35c0 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. - * <p> - * <b>Note:</b> 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; } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/ConstantRealDistribution.java ---------------------------------------------------------------------- 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 862fe75..a9b3383 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; } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java ---------------------------------------------------------------------- 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 40af6e4..fd339b2 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<T> implements Serializable { * RNG instance used to generate samples from the distribution. */ @Deprecated - protected final RandomGenerator random; + protected RandomGenerator random = null; /** * List of random variable values. @@ -81,45 +80,57 @@ public class EnumeratedDistribution<T> implements Serializable { private final double[] cumulativeProbabilities; /** - * Create an enumerated distribution using the given probability mass function - * enumeration. - * <p> - * <b>Note:</b> 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 <T, probability> - * pairs. - * @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. + * XXX TODO: remove once "EnumeratedIntegerDistribution" has been changed. */ - public EnumeratedDistribution(final List<Pair<T, Double>> pmf) + @Deprecated + public EnumeratedDistribution(final RandomGenerator rng, final List<Pair<T, Double>> pmf) throws NotPositiveException, MathArithmeticException, NotFiniteNumberException, NotANumberException { - this(new Well19937c(), pmf); + random = rng; + singletons = new ArrayList<T>(pmf.size()); + final double[] probs = new double[pmf.size()]; + + for (int i = 0; i < pmf.size(); i++) { + final Pair<T, Double> sample = pmf.get(i); + singletons.add(sample.getKey()); + final double p = sample.getValue(); + if (p < 0) { + throw new NotPositiveException(sample.getValue()); + } + if (Double.isInfinite(p)) { + throw new NotFiniteNumberException(p); + } + if (Double.isNaN(p)) { + throw new NotANumberException(); + } + probs[i] = p; + } + + probabilities = MathArrays.normalizeArray(probs, 1.0); + + cumulativeProbabilities = new double[probabilities.length]; + double sum = 0; + for (int i = 0; i < probabilities.length; i++) { + sum += probabilities[i]; + cumulativeProbabilities[i] = sum; + } } /** * Create an enumerated distribution using the given random number generator * and probability mass function enumeration. * - * @param rng random number generator. - * @param pmf probability mass function enumerated as a list of <T, probability> - * pairs. + * @param pmf probability mass function enumerated as a list of + * {@code <T, probability>} pairs. * @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. */ - @Deprecated - public EnumeratedDistribution(final RandomGenerator rng, final List<Pair<T, Double>> pmf) - throws NotPositiveException, MathArithmeticException, NotFiniteNumberException, NotANumberException { - random = rng; - + public EnumeratedDistribution(final List<Pair<T, Double>> pmf) + throws NotPositiveException, + MathArithmeticException, + NotFiniteNumberException, + NotANumberException { singletons = new ArrayList<T>(pmf.size()); final double[] probs = new double[pmf.size()]; http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java b/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java index 9e03b2b..7cf834b 100644 --- a/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/EnumeratedRealDistribution.java @@ -28,8 +28,6 @@ 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.OutOfRangeException; -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.Pair; @@ -37,7 +35,7 @@ import org.apache.commons.math4.util.Pair; * <p>Implementation of a real-valued {@link EnumeratedDistribution}. * * <p>Values with zero-probability are allowed but they do not extend the - * support.<br/> + * support.<br> * Duplicate values are allowed. Probabilities of duplicate values are combined * when computing cumulative probabilities and statistics.</p> * @@ -46,7 +44,7 @@ import org.apache.commons.math4.util.Pair; public class EnumeratedRealDistribution extends AbstractRealDistribution { /** Serializable UID. */ - private static final long serialVersionUID = 20130308L; + private static final long serialVersionUID = 20160311L; /** * {@link EnumeratedDistribution} (using the {@link Double} wrapper) @@ -55,36 +53,9 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution { protected final EnumeratedDistribution<Double> innerDistribution; /** - * Create a discrete real-valued distribution using the given probability mass function - * enumeration. - * <p> - * <b>Note:</b> 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<Double>( - rng, createDistribution(singletons, probabilities)); + public EnumeratedRealDistribution(final double[] singletons, + final double[] probabilities) + throws DimensionMismatchException, + NotPositiveException, + MathArithmeticException, + NotFiniteNumberException, + NotANumberException { + innerDistribution = new EnumeratedDistribution<Double>(createDistribution(singletons, probabilities)); } /** - * Create a discrete real-valued distribution from the input data. Values are assigned - * mass based on their frequency. + * Creates a discrete real-valued distribution from the input data. + * Values are assigned mass based on their frequency. * - * @param rng random number generator used for sampling * @param data input dataset - * @since 3.6 */ - @Deprecated - public EnumeratedRealDistribution(final RandomGenerator rng, final double[] data) { - super(rng); + public EnumeratedRealDistribution(final double[] data) { final Map<Double, Integer> dataMap = new HashMap<Double, Integer>(); for (double value : data) { Integer count = dataMap.get(value); @@ -134,21 +100,10 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution { probabilities[index] = entry.getValue().intValue() / denom; index++; } - innerDistribution = new EnumeratedDistribution<Double>(rng, createDistribution(values, probabilities)); + innerDistribution = new EnumeratedDistribution<Double>(createDistribution(values, probabilities)); } /** - * Create a discrete real-valued distribution from the input data. Values are assigned - * mass based on their frequency. For example, [0,1,1,2] as input creates a distribution - * with values 0, 1 and 2 having probability masses 0.25, 0.5 and 0.25 respectively, - * - * @param data input dataset - * @since 3.6 - */ - public EnumeratedRealDistribution(final double[] data) { - this(new Well19937c(), data); - } - /** * Create the list of Pairs representing the distribution from singletons and probabilities. * * @param singletons values http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/ExponentialDistribution.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/distribution/ExponentialDistribution.java b/src/main/java/org/apache/commons/math4/distribution/ExponentialDistribution.java index 133321e..1dbd6b1 100644 --- a/src/main/java/org/apache/commons/math4/distribution/ExponentialDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/ExponentialDistribution.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.rng.UniformRandomProvider; import org.apache.commons.math4.util.CombinatoricsUtils; import org.apache.commons.math4.util.FastMath; @@ -39,7 +37,7 @@ public class ExponentialDistribution extends AbstractRealDistribution { */ public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9; /** Serializable version identifier */ - private static final long serialVersionUID = 2401296428283614780L; + private static final long serialVersionUID = 20160311L; /** * Used when generating Exponential samples. * Table containing the constants @@ -91,14 +89,7 @@ public class ExponentialDistribution extends AbstractRealDistribution { } /** - * Create an exponential distribution with the given mean. - * <p> - * <b>Note:</b> 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. - * <p> - * <b>Note:</b> 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 + * @since 2.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); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/FDistribution.java ---------------------------------------------------------------------- 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 907d201..bcde9aa 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. - * <p> - * <b>Note:</b> 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. - * <p> - * <b>Note:</b> 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 - * {@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, + public FDistribution(double numeratorDegreesOfFreedom, double denominatorDegreesOfFreedom, double inverseCumAccuracy) throws NotStrictlyPositiveException { - super(rng); - if (numeratorDegreesOfFreedom <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.DEGREES_OF_FREEDOM, numeratorDegreesOfFreedom); http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/GammaDistribution.java ---------------------------------------------------------------------- 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 2377df7..c50c974 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,70 +97,21 @@ public class GammaDistribution extends AbstractRealDistribution { private final double solverAbsoluteAccuracy; /** - * Creates a new gamma distribution with specified values of the shape and - * scale parameters. - * <p> - * <b>Note:</b> 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 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 { - this(shape, scale, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); - } - - /** - * Creates a new gamma distribution with specified values of the shape and - * scale parameters. - * <p> - * <b>Note:</b> 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 - * @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 2.1 */ - public GammaDistribution(double shape, double scale, double inverseCumAccuracy) + public GammaDistribution(double shape, double scale) 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); + this(shape, scale, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); } /** - * Creates a Gamma distribution. + * Creates a distribution. * - * @param rng Random number generator. * @param shape the shape parameter * @param scale the scale parameter * @param inverseCumAccuracy the maximum absolute error in inverse @@ -170,16 +119,11 @@ public class GammaDistribution extends AbstractRealDistribution { * {@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); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/GumbelDistribution.java ---------------------------------------------------------------------- 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 0aa3fb2..be06d09 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. - * <p> - * <b>Note:</b> 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); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/LaplaceDistribution.java ---------------------------------------------------------------------- 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 7e41a29..c85618b 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. - * <p> - * <b>Note:</b> 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); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/LevyDistribution.java ---------------------------------------------------------------------- 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 5f55c83..a8d5793 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. - * <p> - * <b>Note:</b> 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; } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/LogNormalDistribution.java ---------------------------------------------------------------------- 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 8bec045..eafb90e 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,96 +76,40 @@ 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}. - * <p> - * <b>Note:</b> 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. - * <p> - * <b>Note:</b> 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 - * @throws NotStrictlyPositiveException if {@code shape <= 0}. - */ - public LogNormalDistribution(double scale, double shape) - throws NotStrictlyPositiveException { - this(scale, shape, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); - } - - /** - * Create a log-normal distribution using the specified scale, shape and - * inverse cumulative distribution accuracy. - * <p> - * <b>Note:</b> 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) + public LogNormalDistribution(double scale, double shape) throws NotStrictlyPositiveException { - this(rng, scale, shape, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); + this(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); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/LogisticDistribution.java ---------------------------------------------------------------------- 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 14c2a98..1c69804 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. - * <p> - * <b>Note:</b> 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); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/NakagamiDistribution.java ---------------------------------------------------------------------- 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 fa8b0f5..5f7e405 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. - * <p> - * <b>Note:</b> 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. - * <p> - * <b>Note:</b> 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); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java ---------------------------------------------------------------------- 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 01de515..a8330d5 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. - * <p> - * <b>Note:</b> 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. - * <p> - * <b>Note:</b> 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. - * <p> - * <b>Note:</b> 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 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. + * Creates a 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); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/ParetoDistribution.java ---------------------------------------------------------------------- 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 bd074fa..2174322 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. - * <p> - * <b>Note:</b> 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. - * <p> - * <b>Note:</b> 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); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/PoissonDistribution.java ---------------------------------------------------------------------- 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 731a6ac..6cb0129 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; http://git-wip-us.apache.org/repos/asf/commons-math/blob/9867d9f2/src/main/java/org/apache/commons/math4/distribution/TDistribution.java ---------------------------------------------------------------------- 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 302d476..e510556 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. - * <p> - * <b>Note:</b> 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. - * <p> - * <b>Note:</b> 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);