SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
MultinormalGen Class Reference

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

Inheritance diagram for MultinormalGen:
[legend]
Collaboration diagram for MultinormalGen:
[legend]

Public Member Functions

 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. More...
 
double [] getMu ()
 Returns the mean vector used by this generator. More...
 
double getMu (int i)
 Returns the \(i\)-th component of the mean vector for this generator. More...
 
void setMu (double[] mu)
 Sets the mean vector to mu. More...
 
void setMu (int i, double mui)
 Sets the \(i\)-th component of the mean vector to mui. More...
 
DoubleMatrix2D getSigma ()
 Returns the covariance matrix \(\boldsymbol{\Sigma}\) used by this generator. More...
 
void nextPoint (double[] p)
 Generates a point from this multinormal distribution. More...
 
- Public Member Functions inherited from RandomMultivariateGen
abstract void nextPoint (double[] p)
 Generates a random point \(p\) using the the stream contained in this object.
 
void nextArrayOfPoints (double[][] v, int start, int n)
 Generates \(n\) random points. More...
 
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. More...
 
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. More...
 
 MultinormalGen (NormalGen gen1, double[] mu, double[][] sigma)
 Equivalent to MultinormalGen(gen1, mu, new DenseDoubleMatrix2D (sigma)).
 

Protected Attributes

double [] mu
 
DoubleMatrix2D sigma
 
DoubleMatrix2D sqrtSigma
 
double [] temp
 
- Protected Attributes inherited from RandomMultivariateGen
int dimension
 
RandomStream stream
 
RandomVariateGen gen1
 

Static Protected Attributes

static final double MYINF = 37.54
 

Detailed Description

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

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\).

Constructor & Destructor Documentation

◆ MultinormalGen() [1/2]

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.

◆ MultinormalGen() [2/2]

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.

Member Function Documentation

◆ getMu() [1/2]

double [] getMu ( )

Returns the mean vector used by this generator.

Returns
the current mean vector.

◆ getMu() [2/2]

double 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.

◆ getSigma()

DoubleMatrix2D getSigma ( )

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

Returns
the used covariance matrix.

◆ nextPoint()

void nextPoint ( double []  p)

Generates a point from this multinormal distribution.

Parameters
pthe array to be filled with the generated point

◆ setMu() [1/2]

void 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.

◆ setMu() [2/2]

void 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.

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