Package com.irurueta.statistics
Class MultivariateGaussianRandomizer
java.lang.Object
com.irurueta.statistics.MultivariateGaussianRandomizer
Generates pseudo-random values following a multivariate Gaussian distribution
having the specified mean and covariance. By default, mean is equal to zero
and the covariance is equal to the identity (unitary standard deviation).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Matrix
Covariance matrix.private final Random
Instance in charge of generating pseudo-random values.private Matrix
Lower triangular Cholesky decomposition of covariance matrix.private double[]
Contains mean values to be used for random value generation. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.MultivariateGaussianRandomizer
(double[] mean, Matrix covariance) Constructor.MultivariateGaussianRandomizer
(Random internalRandom) Constructor.MultivariateGaussianRandomizer
(Random internalRandom, double[] mean, Matrix covariance) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns covariance to be used for Gaussian random value generation.double[]
getMean()
Returns mean value to be used for Gaussian random value generation.double[]
next()
Generate next set of multivariate Gaussian random values having current mean and covariance of this instance.void
next
(double[] values) Generate next set of multivariate Gaussian random values having current mean and covariance of this instance.final void
setMeanAndCovariance
(double[] mean, Matrix covariance) Sets mean and covariance to generate multivariate Gaussian random values.
-
Field Details
-
mean
private double[] meanContains mean values to be used for random value generation. -
covariance
Covariance matrix. -
l
Lower triangular Cholesky decomposition of covariance matrix. -
internalRandom
Instance in charge of generating pseudo-random values. Secure instances can be used if the generated values need to be ensured "more" random at the expense of higher computational cost.
-
-
Constructor Details
-
MultivariateGaussianRandomizer
public MultivariateGaussianRandomizer()Constructor. -
MultivariateGaussianRandomizer
Constructor. Because neither mean nor covariance are provided, default values will be used instead.- Parameters:
internalRandom
- internal random instance in charge of generating pseudo-random values.- Throws:
NullPointerException
- thrown if provided internal random is null.
-
MultivariateGaussianRandomizer
public MultivariateGaussianRandomizer(double[] mean, Matrix covariance) throws WrongSizeException, InvalidCovarianceMatrixException Constructor.- Parameters:
mean
- mean to be set.covariance
- covariance to be set.- Throws:
WrongSizeException
- if mean length is not compatible with covariance size. Mean length must be equal to size of square covariance matrix.InvalidCovarianceMatrixException
- if provided covariance matrix is not symmetric positive definite.
-
MultivariateGaussianRandomizer
public MultivariateGaussianRandomizer(Random internalRandom, double[] mean, Matrix covariance) throws WrongSizeException, InvalidCovarianceMatrixException Constructor.- Parameters:
internalRandom
- internal random instance in charge of generating pseudo-random values.mean
- mean to be set.covariance
- covariance to be set.- Throws:
WrongSizeException
- if mean length is not compatible with covariance size. Mean length must be equal to size of square covariance matrix.InvalidCovarianceMatrixException
- if provided covariance matrix is not symmetric positive definite.NullPointerException
- thrown if provided internal random is null.
-
-
Method Details
-
getMean
public double[] getMean()Returns mean value to be used for Gaussian random value generation.- Returns:
- mean value.
-
getCovariance
Returns covariance to be used for Gaussian random value generation.- Returns:
- covariance.
-
setMeanAndCovariance
public final void setMeanAndCovariance(double[] mean, Matrix covariance) throws WrongSizeException, InvalidCovarianceMatrixException Sets mean and covariance to generate multivariate Gaussian random values.- Parameters:
mean
- mean to be set.covariance
- covariance to be set.- Throws:
WrongSizeException
- if mean length is not compatible with covariance size. Mean length must be equal to size of square covariance matrix.InvalidCovarianceMatrixException
- if provided covariance matrix is not symmetric positive definite.
-
next
public void next(double[] values) Generate next set of multivariate Gaussian random values having current mean and covariance of this instance.- Parameters:
values
- array where generated random values will be stored.- Throws:
IllegalArgumentException
- if provided array length does not have the same length as provided mean array.
-
next
public double[] next()Generate next set of multivariate Gaussian random values having current mean and covariance of this instance.- Returns:
- a new array containing generated random values.
-