SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.randvarmulti.MultinormalGen Class Reference

Extends RandomMultivariateGen for a multivariate normal (or multinormal) distribution [94] . More...

Inheritance diagram for umontreal.ssj.randvarmulti.MultinormalGen:
umontreal.ssj.randvarmulti.RandomMultivariateGen umontreal.ssj.randvarmulti.MultinormalCholeskyGen umontreal.ssj.randvarmulti.MultinormalPCAGen

Public Member Functions

 MultinormalGen (NormalGen gen1, int d)
 Constructs a generator with the standard multinormal distribution (with \(\boldsymbol{\mu}=\boldsymbol{0}\) and.
double[] getMu ()
 Returns the mean vector used by this generator.
double getMu (int i)
 Returns the \(i\)-th component of the mean vector for this generator.
void setMu (double[] mu)
 Sets the mean vector to mu.
void setMu (int i, double mui)
 Sets the \(i\)-th component of the mean vector to mui.
DoubleMatrix2D getSigma ()
 Returns the covariance matrix \(\boldsymbol{\Sigma}\) used by this generator.
void nextPoint (double[] p)
 Generates a point from this multinormal distribution.
Public Member Functions inherited from umontreal.ssj.randvarmulti.RandomMultivariateGen
void nextArrayOfPoints (double[][] v, int start, int n)
 Generates \(n\) random points.
int getDimension ()
 Returns the dimension of this multivariate generator (the dimension of the random points).
RandomStream getStream ()
 Returns the umontreal.ssj.rng.RandomStream used by this object.
void setStream (RandomStream stream)
 Sets the umontreal.ssj.rng.RandomStream used by this object to stream.

Protected Member Functions

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

Detailed Description

Extends RandomMultivariateGen for a multivariate normal (or multinormal) distribution [94] .

The \(d\)-dimensional multivariate normal distribution with mean vector

\(\boldsymbol{\mu}\in\mathbb{R}^d\) and (symmetric positive-definite) covariance matrix \(\boldsymbol{\Sigma}\), denoted \(N(\boldsymbol{\mu}, \boldsymbol{\Sigma})\), has density

\[ f(\mathbf{X})=\frac{1}{\sqrt{(2\pi)^d\det(\boldsymbol{\Sigma})}} \exp\left(-(\mathbf{X}- \boldsymbol{\mu})^{\!\mathsf{t}}\boldsymbol{\Sigma}^{-1}(\mathbf{X}- \boldsymbol{\mu})/2\right), \]

for all \(\mathbf{X}\in\mathbb{R}^d\), and \(\mathbf{X}^{\mathsf{t}}\) is the transpose vector of \(\mathbf{X}\). If \(\mathbf{Z}\sim N(\boldsymbol{0}, \mathbf{I})\) where \(\mathbf{I}\) is the identity matrix, \(\mathbf{Z}\) is said to have the standard multinormal distribution.

For the special case \(d=2\), if the random vector \(\mathbf{X}= (X_1, X_2)^{\mathsf{t}}\) has a bivariate normal distribution, then it has mean \(\boldsymbol{\mu}= (\mu_1, \mu_2)^{\mathsf{t}}\), and covariance matrix

\[ \boldsymbol{\Sigma}= \left[\begin{array}{cc} \sigma_1^2 & \rho\sigma_1\sigma_2 \\ \rho\sigma_1\sigma_2 & \sigma_2^2 \end{array}\right] \]

if and only if \(\mathrm{Var}[X_1] = \sigma_1^2\), \(\mathrm{Var}[X_2] = \sigma_2^2\), and the linear correlation between \(X_1\) and \(X_2\) is \(\rho\), where \(\sigma_1 > 0\), \(\sigma_2 > 0\), and \(-1 \le\rho\le1\).

Definition at line 70 of file MultinormalGen.java.

Constructor & Destructor Documentation

◆ MultinormalGen() [1/3]

umontreal.ssj.randvarmulti.MultinormalGen.MultinormalGen ( NormalGen gen1,
int d )

Constructs a generator with the standard multinormal distribution (with \(\boldsymbol{\mu}=\boldsymbol{0}\) and.

\(\boldsymbol{\Sigma}= \mathbf{I}\)) in \(d\) dimensions. Each vector \(\mathbf{Z}\) will be generated via \(d\) successive calls to gen1, which must be a standard normal generator.

Parameters
gen1the one-dimensional generator
dthe dimension of the generated vectors
Exceptions
IllegalArgumentExceptionif the one-dimensional normal generator uses a normal distribution with \(\mu\) not equal to 0, or \(\sigma\) not equal to 1.
IllegalArgumentExceptionif `d` is negative.
NullPointerExceptionif `gen1` is `null`.

Definition at line 120 of file MultinormalGen.java.

◆ MultinormalGen() [2/3]

umontreal.ssj.randvarmulti.MultinormalGen.MultinormalGen ( NormalGen gen1,
double[] mu,
DoubleMatrix2D sigma )
protected

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 \(\mathbf{Z}\) is generated by calling \(d\) times the generator gen1, which must be standard normal.

Parameters
gen1the one-dimensional generator
muthe mean vector.
sigmathe covariance matrix.
Exceptions
NullPointerExceptionif any argument is `null`.
IllegalArgumentExceptionif the length of the mean vector is incompatible with the dimensions of the covariance matrix.

Definition at line 146 of file MultinormalGen.java.

◆ MultinormalGen() [3/3]

umontreal.ssj.randvarmulti.MultinormalGen.MultinormalGen ( NormalGen gen1,
double[] mu,
double sigma[][] )
protected

Member Function Documentation

◆ getMu() [1/2]

double[] umontreal.ssj.randvarmulti.MultinormalGen.getMu ( )

Returns the mean vector used by this generator.

Returns
the current mean vector.

Definition at line 165 of file MultinormalGen.java.

◆ getMu() [2/2]

double umontreal.ssj.randvarmulti.MultinormalGen.getMu ( int i)

Returns the \(i\)-th component of the mean vector for this generator.

Parameters
ithe index of the required component.
Returns
the value of \(\mu_i\).
Exceptions
ArrayIndexOutOfBoundsExceptionif `i` is negative or greater than or equal to getDimension.

Definition at line 178 of file MultinormalGen.java.

◆ getSigma()

DoubleMatrix2D umontreal.ssj.randvarmulti.MultinormalGen.getSigma ( )

Returns the covariance matrix \(\boldsymbol{\Sigma}\) used by this generator.

Returns
the used covariance matrix.

Definition at line 214 of file MultinormalGen.java.

◆ nextPoint()

void umontreal.ssj.randvarmulti.MultinormalGen.nextPoint ( double[] p)

Generates a point from this multinormal distribution.

Parameters
pthe array to be filled with the generated point

Reimplemented from umontreal.ssj.randvarmulti.RandomMultivariateGen.

Reimplemented in umontreal.ssj.randvarmulti.MultinormalCholeskyGen, and umontreal.ssj.randvarmulti.MultinormalPCAGen.

Definition at line 223 of file MultinormalGen.java.

◆ setMu() [1/2]

void umontreal.ssj.randvarmulti.MultinormalGen.setMu ( double[] mu)

Sets the mean vector to mu.

Parameters
muthe new mean vector.
Exceptions
NullPointerExceptionif `mu` is `null`.
IllegalArgumentExceptionif the length of `mu` does not correspond to getDimension.

Definition at line 190 of file MultinormalGen.java.

◆ setMu() [2/2]

void umontreal.ssj.randvarmulti.MultinormalGen.setMu ( int i,
double mui )

Sets the \(i\)-th component of the mean vector to mui.

Parameters
ithe index of the modified component.
muithe new value of \(\mu_i\).
Exceptions
ArrayIndexOutOfBoundsExceptionif `i` is negative or greater than or equal to getDimension.

Definition at line 204 of file MultinormalGen.java.


The documentation for this class was generated from the following file: