Class NormalRVG
- java.lang.Object
-
- dev.nm.stat.random.rng.multivariate.NormalRVG
-
- All Implemented Interfaces:
RandomVectorGenerator
,Seedable
public class NormalRVG extends Object implements RandomVectorGenerator
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 isrmvnorm
in packagemvtnorm
.- See Also:
- Wikipedia: Multivariate normal distribution
- "Jin Wang, Chunlei Liu. "Generating Multivariate Mixture of Normal Distributions using a Modified Cholesky Decomposition," Simulation Conference, 2006. WSC 06. Proceedings of the Winter. p. 342 - 347. 3-6 Dec. 2006."
-
-
Constructor Summary
Constructors Constructor Description NormalRVG(int dim)
Constructs a standard multivariate Normal random vector generator.NormalRVG(Vector mu, Matrix sigma)
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]
nextVector()
Gets the next random vector.void
seed(long... seeds)
Seed the random number/vector/scenario generator to produce repeatable experiments.
-
-
-
Constructor Detail
-
NormalRVG
public NormalRVG(Vector mu, Matrix sigma, double epsilon, RandomStandardNormalGenerator rnorm)
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
public NormalRVG(Vector mu, Matrix sigma, RandomStandardNormalGenerator rnorm)
Constructs a multivariate Normal random vector generator.- Parameters:
mu
- the meansigma
- the covariance matrixrnorm
- a random standard Normal number generator
-
NormalRVG
public NormalRVG(Vector mu, Matrix sigma)
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 Detail
-
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
-
-