SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.random.multivariate
Class Gaussian

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.random.multivariate.Gaussian
All Implemented Interfaces:
RandomVectorGenerator

public class Gaussian
extends java.lang.Object
implements RandomVectorGenerator

This class generates multivariate Normal random numbers by implementing 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
Gaussian(Vector mu, Matrix sigma)
          Construct a multivariate Gaussian random vector generator.
Gaussian(Vector mu, Matrix sigma, RandomNumberGenerator rng, double epsilon)
          Construct a multivariate Gaussian random vector generator.
 
Method Summary
 double[] nextVector()
          Get the next random vector.
 void seed(long... seeds)
          Seed the random number generator to produce repeatable sequences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Gaussian

public Gaussian(Vector mu,
                Matrix sigma,
                RandomNumberGenerator rng,
                double epsilon)
Construct a multivariate Gaussian random vector generator.

Parameters:
mu - the mean
sigma - the covariance matrix
rng - a uniform random number generator
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0

Gaussian

public Gaussian(Vector mu,
                Matrix sigma)
Construct a multivariate Gaussian random vector generator.

Parameters:
mu - the mean
sigma - the covariance matrix
Method Detail

seed

public void seed(long... seeds)
Description copied from interface: RandomVectorGenerator
Seed the random number generator to produce repeatable sequences.

Specified by:
seed in interface RandomVectorGenerator
Parameters:
seeds - the seeds

nextVector

public double[] nextVector()
Description copied from interface: RandomVectorGenerator
Get the next random vector.

Specified by:
nextVector in interface RandomVectorGenerator
Returns:
the next random vector

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.