SSJ
V. 2.6.

umontreal.iro.lecuyer.randvarmulti
Class MultinormalCholeskyGen

java.lang.Object
  extended by umontreal.iro.lecuyer.randvarmulti.RandomMultivariateGen
      extended by umontreal.iro.lecuyer.randvarmulti.MultinormalGen
          extended by umontreal.iro.lecuyer.randvarmulti.MultinormalCholeskyGen

public class MultinormalCholeskyGen
extends MultinormalGen

Extends MultinormalGen for a multivariate normal distribution, generated via a Cholesky decomposition of the covariance matrix. The covariance matrix Σ is decomposed (by the constructor) as Σ = AAt where A is a lower-triangular matrix (this is the Cholesky decomposition), and X is generated via

X = μ + AZ,

where Z is a d-dimensional vector of independent standard normal random variates, and At is the transpose of A. The covariance matrix Σ must be positive-definite, otherwise the Cholesky decomposition will fail. The decomposition method uses the CholeskyDecomposition class in colt.


Constructor Summary
MultinormalCholeskyGen(NormalGen gen1, double[] mu, double[][] sigma)
          Equivalent to MultinormalCholeskyGen(gen1, mu, new DenseDoubleMatrix2D(sigma)).
MultinormalCholeskyGen(NormalGen gen1, double[] mu, cern.colt.matrix.DoubleMatrix2D sigma)
          Constructs a multinormal generator with mean vector mu and covariance matrix sigma.
 
Method Summary
 cern.colt.matrix.DoubleMatrix2D getCholeskyDecompSigma()
          Returns the lower-triangular matrix A in the Cholesky decomposition of Σ.
 void nextPoint(double[] p)
          Generates a point from this multinormal distribution.
static void nextPoint(NormalGen gen1, double[] mu, double[][] sigma, double[] p)
          Equivalent to nextPoint(gen1, mu, new DenseDoubleMatrix2D(sigma), p).
static void nextPoint(NormalGen gen1, double[] mu, cern.colt.matrix.DoubleMatrix2D sigma, double[] p)
          Generates a d-dimensional vector from the multinormal distribution with mean vector mu and covariance matrix sigma, using the one-dimensional normal generator gen1 to generate the coordinates of Z, and using the Cholesky decomposition of Σ.
 void setSigma(cern.colt.matrix.DoubleMatrix2D sigma)
          Sets the covariance matrix Σ of this multinormal generator to sigma (and recomputes A).
 
Methods inherited from class umontreal.iro.lecuyer.randvarmulti.MultinormalGen
getMu, getMu, getSigma, setMu, setMu
 
Methods inherited from class umontreal.iro.lecuyer.randvarmulti.RandomMultivariateGen
getDimension, getStream, nextArrayOfPoints, setStream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultinormalCholeskyGen

public MultinormalCholeskyGen(NormalGen gen1,
                              double[] mu,
                              double[][] sigma)
Equivalent to MultinormalCholeskyGen(gen1, mu, new DenseDoubleMatrix2D(sigma)).

Parameters:
gen1 - the one-dimensional generator
mu - the mean vector.
sigma - the covariance matrix.
Throws:
NullPointerException - if any argument is null.
IllegalArgumentException - if the length of the mean vector is incompatible with the dimensions of the covariance matrix.

MultinormalCholeskyGen

public MultinormalCholeskyGen(NormalGen gen1,
                              double[] mu,
                              cern.colt.matrix.DoubleMatrix2D sigma)
Constructs a multinormal generator with mean vector mu and covariance matrix sigma. The mean vector must have the same length as the dimensions of the covariance matrix, which must be symmetric and positive-definite. If any of the above conditions is violated, an exception is thrown. The vector Z is generated by calling d times the generator gen1, which must be a standard normal 1-dimensional generator.

Parameters:
gen1 - the one-dimensional generator
mu - the mean vector.
sigma - the covariance matrix.
Throws:
NullPointerException - if any argument is null.
IllegalArgumentException - if the length of the mean vector is incompatible with the dimensions of the covariance matrix.
Method Detail

getCholeskyDecompSigma

public cern.colt.matrix.DoubleMatrix2D getCholeskyDecompSigma()
Returns the lower-triangular matrix A in the Cholesky decomposition of Σ.

Returns:
the Cholesky decomposition of the covariance matrix.

setSigma

public void setSigma(cern.colt.matrix.DoubleMatrix2D sigma)
Sets the covariance matrix Σ of this multinormal generator to sigma (and recomputes A).

Parameters:
sigma - the new covariance matrix.
Throws:
IllegalArgumentException - if sigma has incorrect dimensions.

nextPoint

public static void nextPoint(NormalGen gen1,
                             double[] mu,
                             double[][] sigma,
                             double[] p)
Equivalent to nextPoint(gen1, mu, new DenseDoubleMatrix2D(sigma), p).


nextPoint

public static void nextPoint(NormalGen gen1,
                             double[] mu,
                             cern.colt.matrix.DoubleMatrix2D sigma,
                             double[] p)
Generates a d-dimensional vector from the multinormal distribution with mean vector mu and covariance matrix sigma, using the one-dimensional normal generator gen1 to generate the coordinates of Z, and using the Cholesky decomposition of Σ. The resulting vector is put into p. Note that this static method will be very slow for large dimensions, since it computes the Cholesky decomposition at every call. It is therefore recommended to use a MultinormalCholeskyGen object instead, if the method is to be called more than once.

Parameters:
p - the array to be filled with the generated point.
Throws:
IllegalArgumentException - if the one-dimensional normal generator uses a normal distribution with μ not equal to 0, or σ not equal to 1.
IllegalArgumentException - if the length of the mean vector is different from the dimensions of the covariance matrix, or if the covariance matrix is not symmetric and positive-definite.
NullPointerException - if any argument is null.

nextPoint

public void nextPoint(double[] p)
Generates a point from this multinormal distribution. This is much faster than the static method as it computes the singular value decomposition matrix only once in the constructor.

Overrides:
nextPoint in class MultinormalGen
Parameters:
p - the array to be filled with the generated point

SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.