Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.randvarmulti
Class MultinormalPCAGen

    java.lang.Object
      umontreal.iro.lecuyer.randvarmulti.RandomMultivariateGen
          umontreal.iro.lecuyer.randvarmulti.MultinormalGen
              umontreal.iro.lecuyer.randvarmulti.MultinormalPCAGen

    public class MultinormalPCAGen

extends MultinormalGen

Extends `MultinormalGen` for a multivariate normal distribution, generated via the method of principal components analysis (PCA) of the covariance matrix. The covariance matrix Σ is decomposed (by the constructor) as Σ = V Λ Vt where V is an orthogonal matrix and Λ is the diagonal matrix made up of the eigenvalues of Σ. Vt is the transpose matrix of V. The eigenvalues are ordered from the largest (λ1) to the smallest (λd). The random multinormal vector X is generated via

X = μ + A Z,

where A = V()1/2, and Z is a d-dimensional vector of independent standard normal random variates. The decomposition method uses the `SingularValueDecomposition` class in `colt`.

Constructor Summary
`MultinormalPCAGen(NormalGen gen1, double[] mu, double[][] sigma)` Equivalent to `MultinormalPCAGen``(gen1, mu, new DenseDoubleMatrix2D(sigma))`.
`MultinormalPCAGen(NormalGen gen1, double[] mu, DoubleMatrix2D sigma)` Constructs a multinormal generator with mean vector `mu` and covariance matrix `sigma`.

Method Summary
`static DoubleMatrix2D` | `decompPCA(double[][] sigma)` Computes the decomposition `sigma` = Σ = V Λ Vt.
`static DoubleMatrix2D` | `decompPCA(DoubleMatrix2D sigma)` Computes the decomposition `sigma` = Σ = V Λ Vt.
`double[]` | `getLambda()` Returns the eigenvalues of Σ in decreasing order.
`static double[]` | `getLambda(DoubleMatrix2D sigma)` Computes and returns the eigenvalues of `sigma` in decreasing order.
`DoubleMatrix2D` | `getPCADecompSigma()` Returns the matrix A = V()1/2 of this object.
`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, 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 PCA decomposition of Σ.
`void` | `setSigma(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

### MultinormalPCAGen

    public MultinormalPCAGen(NormalGen gen1,
                             double[] mu,
                             double[][] sigma)

  Equivalent to `MultinormalPCAGen``(gen1, mu, new DenseDoubleMatrix2D(sigma))`.

### MultinormalPCAGen

    public MultinormalPCAGen(NormalGen gen1,
                             double[] mu,
                             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 semi-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

### decompPCA

    public static DoubleMatrix2D decompPCA(double[][] sigma)

  Computes the decomposition `sigma` = Σ = V Λ Vt. Returns A = V()1/2.

### decompPCA

    public static DoubleMatrix2D decompPCA(DoubleMatrix2D sigma)

  Computes the decomposition `sigma` = Σ = V Λ Vt. Returns A = V()1/2.

### getPCADecompSigma

    public DoubleMatrix2D getPCADecompSigma()

  Returns the matrix A = V()1/2 of this object.

  Returns:
    the PCA square root of the covariance matrix

### getLambda

    public static double[] getLambda(DoubleMatrix2D sigma)

  Computes and returns the eigenvalues of `sigma` in decreasing order.

### getLambda

    public double[] getLambda()

  Returns the eigenvalues of Σ in decreasing order.

### setSigma

    public void setSigma(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,
                                 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 PCA decomposition of Σ. The resulting vector is put into `p`. Note that this static method will be very slow for large dimensions, because it recomputes the singular value decomposition at every call. It is therefore recommended to use a `MultinormalPCAGen` 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 static void nextPoint(NormalGen gen1,
                                 double[] mu,
                                 double[][] sigma,
                                 double[] p)

  Equivalent to `nextPoint``(gen1, mu, new DenseDoubleMatrix2D(sigma), p)`.

### 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

Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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