[MATH-1154] Add clarification to ctor javadoc of all distributions to pass a null random generator in case no sampling is needed.

This commit is contained in:
Thomas Neidhart 2014-12-15 21:21:09 +01:00
parent 59fe593a42
commit 809f0f89cb
31 changed files with 383 additions and 36 deletions

View File

@ -18,11 +18,11 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.special.Gamma;
import org.apache.commons.math3.special.Beta;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.special.Beta;
import org.apache.commons.math3.special.Gamma;
import org.apache.commons.math3.util.FastMath;
/**
* Implements the Beta distribution.
@ -51,6 +51,13 @@ 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.
*
* @param alpha First shape parameter (must be positive).
* @param beta Second shape parameter (must be positive).
@ -61,6 +68,13 @@ 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.
*
* @param alpha First shape parameter (must be positive).
* @param beta Second shape parameter (must be positive).

View File

@ -16,13 +16,13 @@
*/
package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.NotPositiveException;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.special.Beta;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.special.Beta;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the binomial distribution.
@ -41,6 +41,13 @@ public class BinomialDistribution extends AbstractIntegerDistribution {
/**
* Create a binomial distribution with the given number of trials and
* probability of success.
* <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 trials Number of trials.
* @param p Probability of success.

View File

@ -19,9 +19,9 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the Cauchy distribution.
@ -55,6 +55,13 @@ 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.
*
* @param median Median for this distribution.
* @param scale Scale parameter for this distribution.
@ -65,6 +72,13 @@ 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.
*
* @param median Median for this distribution.
* @param scale Scale parameter for this distribution.

View File

@ -50,6 +50,13 @@ public class ChiSquaredDistribution extends AbstractRealDistribution {
/**
* Create a Chi-Squared 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

View File

@ -81,6 +81,13 @@ public class EnumeratedDistribution<T> implements Serializable {
/**
* 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.

View File

@ -18,6 +18,7 @@ package org.apache.commons.math3.distribution;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.MathArithmeticException;
import org.apache.commons.math3.exception.NotANumberException;
@ -51,6 +52,13 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
/**
* Create a discrete distribution using the given probability mass function
* definition.
* <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.

View File

@ -53,6 +53,13 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution {
/**
* Create a discrete 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.

View File

@ -19,11 +19,11 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.util.CombinatoricsUtils;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.util.ResizableDoubleArray;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
/**
* Implementation of the exponential distribution.
@ -91,6 +91,14 @@ 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.
*
* @param mean mean of this distribution.
*/
public ExponentialDistribution(double mean) {
@ -99,6 +107,13 @@ 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.
*
* @param mean Mean of this distribution.
* @param inverseCumAccuracy Maximum absolute error in inverse

View File

@ -19,10 +19,10 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.special.Beta;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.special.Beta;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the F-distribution.
@ -51,6 +51,13 @@ public class FDistribution extends AbstractRealDistribution {
/**
* 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.
*
* @param numeratorDegreesOfFreedom Numerator degrees of freedom.
* @param denominatorDegreesOfFreedom Denominator degrees of freedom.
@ -68,6 +75,13 @@ 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.
*
* @param numeratorDegreesOfFreedom Numerator degrees of freedom.
* @param denominatorDegreesOfFreedom Denominator degrees of freedom.

View File

@ -18,10 +18,10 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.special.Gamma;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.special.Gamma;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the Gamma distribution.
@ -100,6 +100,13 @@ public class GammaDistribution extends AbstractRealDistribution {
/**
* 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
@ -113,6 +120,13 @@ public class GammaDistribution extends AbstractRealDistribution {
/**
* 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

View File

@ -18,9 +18,9 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the geometric distribution.
@ -38,6 +38,13 @@ public class GeometricDistribution extends AbstractIntegerDistribution {
/**
* Create a geometric distribution with the given probability of success.
* <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 p probability of success.
* @throws OutOfRangeException if {@code p <= 0} or {@code p > 1}.

View File

@ -50,6 +50,13 @@ public class GumbelDistribution 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.
*
* @param mu location parameter
* @param beta scale parameter (must be positive)

View File

@ -21,9 +21,9 @@ import org.apache.commons.math3.exception.NotPositiveException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the hypergeometric distribution.
@ -48,6 +48,13 @@ public class HypergeometricDistribution extends AbstractIntegerDistribution {
/**
* Construct a new hypergeometric distribution with the specified population
* size, number of successes in the population, and sample size.
* <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 populationSize Population size.
* @param numberOfSuccesses Number of successes in the population.

View File

@ -42,6 +42,13 @@ public class LaplaceDistribution 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.
*
* @param mu location parameter
* @param beta scale parameter (must be positive)

View File

@ -18,6 +18,7 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.special.Erf;
import org.apache.commons.math3.util.FastMath;
@ -41,6 +42,24 @@ public class LevyDistribution extends AbstractRealDistribution {
/** Half of c (for calculations). */
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.
*
* @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

View File

@ -20,10 +20,10 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.special.Erf;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.special.Erf;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the log-normal (gaussian) distribution.
@ -82,6 +82,13 @@ public class LogNormalDistribution extends AbstractRealDistribution {
* 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);
@ -89,6 +96,13 @@ public class LogNormalDistribution extends AbstractRealDistribution {
/**
* 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
@ -102,6 +116,13 @@ public class LogNormalDistribution extends AbstractRealDistribution {
/**
* 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

View File

@ -44,6 +44,13 @@ public class LogisticDistribution 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.
*
* @param mu location parameter
* @param s scale parameter (must be positive)

View File

@ -16,8 +16,8 @@
*/
package org.apache.commons.math3.distribution;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NotPositiveException;
@ -33,8 +33,17 @@ import org.apache.commons.math3.util.Pair;
*/
public class MixtureMultivariateNormalDistribution
extends MixtureMultivariateRealDistribution<MultivariateNormalDistribution> {
/**
* Creates a multivariate normal mixture distribution.
* <p>
* <b>Note:</b> this constructor will implicitly create an instance of
* {@link org.apache.commons.math3.random.Well19937c 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 weights Weights of each component.
* @param means Mean vector for each component.
@ -49,6 +58,14 @@ public class MixtureMultivariateNormalDistribution
/**
* Creates a mixture model from a list of distributions and their
* associated weights.
* <p>
* <b>Note:</b> this constructor will implicitly create an instance of
* {@link org.apache.commons.math3.random.Well19937c 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 components List of (weight, distribution) pairs from which to sample.
*/

View File

@ -16,11 +16,12 @@
*/
package org.apache.commons.math3.distribution;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NotPositiveException;
import org.apache.commons.math3.exception.MathArithmeticException;
import org.apache.commons.math3.exception.NotPositiveException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
@ -44,6 +45,13 @@ public class MixtureMultivariateRealDistribution<T extends MultivariateRealDistr
/**
* Creates a mixture model from a list of distributions and their
* associated weights.
* <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 components List of (weight, distribution) pairs from which to sample.
*/

View File

@ -57,6 +57,13 @@ public class MultivariateNormalDistribution
* The number of dimensions is equal to the length of the mean vector
* and to the number of rows and columns of the covariance matrix.
* It is frequently written as "p" in formulae.
* <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 means Vector of means.
* @param covariances Covariance matrix.

View File

@ -48,6 +48,13 @@ public class NakagamiDistribution 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.
*
* @param mu shape parameter
* @param omega scale parameter (must be positive)
@ -60,6 +67,13 @@ public class NakagamiDistribution 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.
*
* @param mu shape parameter
* @param omega scale parameter (must be positive)

View File

@ -21,10 +21,10 @@ import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.special.Erf;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.special.Erf;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the normal (gaussian) distribution.
@ -54,6 +54,13 @@ 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);
@ -61,6 +68,13 @@ public class NormalDistribution extends AbstractRealDistribution {
/**
* 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.
*
* @param mean Mean for this distribution.
* @param sd Standard deviation for this distribution.
@ -74,6 +88,13 @@ public class NormalDistribution extends AbstractRealDistribution {
/**
* 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.

View File

@ -20,9 +20,9 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the Pareto distribution.
@ -72,6 +72,13 @@ public class ParetoDistribution extends AbstractRealDistribution {
/**
* 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.
*
* @param scale the scale parameter of this distribution
* @param shape the shape parameter of this distribution
@ -85,6 +92,13 @@ public class ParetoDistribution extends AbstractRealDistribution {
/**
* 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
@ -97,7 +111,7 @@ public class ParetoDistribution extends AbstractRealDistribution {
}
/**
* Creates a log-normal distribution.
* Creates a Pareto distribution.
*
* @param rng Random number generator.
* @param scale Scale parameter of this distribution.
@ -110,7 +124,7 @@ public class ParetoDistribution extends AbstractRealDistribution {
}
/**
* Creates a log-normal distribution.
* Creates a Pareto distribution.
*
* @param rng Random number generator.
* @param scale Scale parameter of this distribution.

View File

@ -19,11 +19,11 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.special.Beta;
import org.apache.commons.math3.util.CombinatoricsUtils;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
/**
* <p>
@ -77,6 +77,13 @@ public class PascalDistribution extends AbstractIntegerDistribution {
/**
* Create a Pascal distribution with the given number of successes and
* probability of success.
* <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 r Number of successes.
* @param p Probability of success.

View File

@ -18,12 +18,12 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.special.Gamma;
import org.apache.commons.math3.util.CombinatoricsUtils;
import org.apache.commons.math3.util.MathUtils;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.special.Gamma;
import org.apache.commons.math3.util.CombinatoricsUtils;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.util.MathUtils;
/**
* Implementation of the Poisson distribution.
@ -65,6 +65,13 @@ public class PoissonDistribution extends AbstractIntegerDistribution {
/**
* Creates a new Poisson distribution with specified 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.
*
* @param p the Poisson mean
* @throws NotStrictlyPositiveException if {@code p <= 0}.
@ -76,6 +83,13 @@ public class PoissonDistribution extends AbstractIntegerDistribution {
/**
* Creates a new Poisson distribution with specified mean, convergence
* criterion and maximum number of iterations.
* <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 p Poisson mean.
* @param epsilon Convergence criterion for cumulative probabilities.

View File

@ -47,6 +47,13 @@ public class TDistribution extends AbstractRealDistribution {
/**
* 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.
*
* @param degreesOfFreedom Degrees of freedom.
* @throws NotStrictlyPositiveException if {@code degreesOfFreedom <= 0}
@ -59,6 +66,13 @@ 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.
*
* @param degreesOfFreedom Degrees of freedom.
* @param inverseCumAccuracy the maximum absolute error in inverse

View File

@ -21,9 +21,9 @@ import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the triangular real distribution.
@ -48,6 +48,13 @@ public class TriangularDistribution extends AbstractRealDistribution {
/**
* Creates a triangular real distribution using the given lower limit,
* upper limit, and mode.
* <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 a Lower limit of this distribution (inclusive).
* @param b Upper limit of this distribution (inclusive).

View File

@ -41,6 +41,13 @@ public class UniformIntegerDistribution extends AbstractIntegerDistribution {
/**
* Creates a new uniform integer distribution using the given lower and
* upper bounds (both inclusive).
* <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 lower Lower bound (inclusive) of this distribution.
* @param upper Upper bound (inclusive) of this distribution.

View File

@ -47,6 +47,13 @@ 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.
* <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 UniformRealDistribution() {
this(0, 1);
@ -55,6 +62,13 @@ public class UniformRealDistribution extends AbstractRealDistribution {
/**
* Create a uniform real distribution using the given lower and upper
* bounds.
* <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 lower Lower bound of this distribution (inclusive).
* @param upper Upper bound of this distribution (exclusive).

View File

@ -17,13 +17,13 @@
package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.special.Gamma;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.special.Gamma;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the Weibull distribution. This implementation uses the
@ -61,6 +61,13 @@ public class WeibullDistribution extends AbstractRealDistribution {
/**
* Create a Weibull distribution with the given shape and scale and a
* location equal to zero.
* <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 alpha Shape parameter.
* @param beta Scale parameter.
@ -75,6 +82,13 @@ 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.
* <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 alpha Shape parameter.
* @param beta Scale parameter.

View File

@ -19,9 +19,9 @@ package org.apache.commons.math3.distribution;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.Well19937c;
import org.apache.commons.math3.util.FastMath;
/**
* Implementation of the Zipf distribution.
@ -47,6 +47,13 @@ public class ZipfDistribution extends AbstractIntegerDistribution {
/**
* Create a new Zipf distribution with the given number of elements and
* exponent.
* <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 numberOfElements Number of elements.
* @param exponent Exponent.