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 is rmvnorm in package mvtnorm.

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 Details

    • NormalRVG

      public NormalRVG(Vector mu, Matrix sigma, double epsilon, RandomStandardNormalGenerator rnorm)
      Constructs a multivariate Normal random vector generator.
      Parameters:
      mu - the mean
      sigma - the covariance matrix
      epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
      rnorm - 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 mean
      sigma - the covariance matrix
      rnorm - a random standard Normal number generator
    • NormalRVG

      public NormalRVG(Vector mu, Matrix sigma)
      Constructs a multivariate Normal random vector generator.
      Parameters:
      mu - the mean
      sigma - 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.
      Specified by:
      seed in interface Seedable
      Parameters:
      seeds - the seeds
    • nextVector

      public double[] nextVector()
      Description copied from interface: RandomVectorGenerator
      Gets the next random vector.
      Specified by:
      nextVector in interface RandomVectorGenerator
      Returns:
      the next random vector