Class NormalRVG
java.lang.Object
dev.nm.stat.random.rng.multivariate.NormalRVG
- All Implemented Interfaces:
RandomVectorGenerator
,Seedable
A multivariate Normal random vector is said to be p-variate normally
distributed if every linear combination of its p components has a univariate
normal distribution. This implementation uses the "Best Approximation of
Indefinite Matrices" in the reference. In the case where the covariance
matrix is not positive definite, we force the diagonal elements in the eigen
decomposition to a small non-negative number, e.g., 0. Then, we re-construct
a positive definite matrix from the new diagonal elements.
The R equivalent function is
rmvnorm
in package mvtnorm
.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionNormalRVG
(int dim) Constructs a standard multivariate Normal random vector generator.Constructs a multivariate Normal random vector generator.NormalRVG
(Vector mu, Matrix sigma, double epsilon, RandomStandardNormalGenerator rnorm) Constructs a multivariate Normal random vector generator.NormalRVG
(Vector mu, Matrix sigma, RandomStandardNormalGenerator rnorm) Constructs a multivariate Normal random vector generator. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
Gets the next random vector.void
seed
(long... seeds) Seed the random number/vector/scenario generator to produce repeatable experiments.
-
Constructor Details
-
NormalRVG
Constructs a multivariate Normal random vector generator.- Parameters:
mu
- the meansigma
- the covariance matrixepsilon
- a precision parameter: when a number |x| ≤ ε, it is considered 0rnorm
- a random standard Normal number generator
-
NormalRVG
Constructs a multivariate Normal random vector generator.- Parameters:
mu
- the meansigma
- the covariance matrixrnorm
- a random standard Normal number generator
-
NormalRVG
Constructs a multivariate Normal random vector generator.- Parameters:
mu
- the meansigma
- the covariance matrix
-
NormalRVG
public NormalRVG(int dim) Constructs a standard multivariate Normal random vector generator.- Parameters:
dim
- the dimension
-
-
Method Details
-
seed
public void seed(long... seeds) Description copied from interface:Seedable
Seed the random number/vector/scenario generator to produce repeatable experiments. -
nextVector
public double[] nextVector()Description copied from interface:RandomVectorGenerator
Gets the next random vector.- Specified by:
nextVector
in interfaceRandomVectorGenerator
- Returns:
- the next random vector
-