SSJ
3.3.1
Stochastic Simulation in Java
|
Extends RandomMultivariateGen for a multivariate normal (or multinormal) distribution [98] . More...
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 |
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\).
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.
gen1 | the one-dimensional generator |
d | the dimension of the generated vectors |
IllegalArgumentException | if the one-dimensional normal generator uses a normal distribution with \(\mu\) not equal to 0, or \(\sigma\) not equal to 1. |
IllegalArgumentException | if d is negative. |
NullPointerException | if gen1 is null . |
|
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.
gen1 | the one-dimensional generator |
mu | the mean vector. |
sigma | the covariance matrix. |
NullPointerException | if any argument is null . |
IllegalArgumentException | if the length of the mean vector is incompatible with the dimensions of the covariance matrix. |
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.
i | the index of the required component. |
ArrayIndexOutOfBoundsException | if i is negative or greater than or equal to getDimension. |
DoubleMatrix2D getSigma | ( | ) |
Returns the covariance matrix \(\boldsymbol{\Sigma}\) used by this generator.
void nextPoint | ( | double [] | p | ) |
Generates a point from this multinormal distribution.
p | the array to be filled with the generated point |
void setMu | ( | double [] | mu | ) |
Sets the mean vector to mu
.
mu | the new mean vector. |
NullPointerException | if mu is null . |
IllegalArgumentException | if the length of mu does not correspond to getDimension. |
void setMu | ( | int | i, |
double | mui | ||
) |
Sets the \(i\)-th component of the mean vector to mui
.
i | the index of the modified component. |
mui | the new value of \(\mu_i\). |
ArrayIndexOutOfBoundsException | if i is negative or greater than or equal to getDimension. |