Class MultivariateGaussianRandomizer

java.lang.Object
com.irurueta.statistics.MultivariateGaussianRandomizer

public class MultivariateGaussianRandomizer extends Object
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 Details

    • mean

      private double[] mean
      Contains mean values to be used for random value generation.
    • covariance

      private Matrix covariance
      Covariance matrix.
    • l

      private Matrix l
      Lower triangular Cholesky decomposition of covariance matrix.
    • internalRandom

      private final Random 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

      public MultivariateGaussianRandomizer(Random internalRandom)
      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

      public Matrix 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.