jml.random
Class MultivariateGaussianDistribution

java.lang.Object
  extended by jml.random.MultivariateGaussianDistribution

public class MultivariateGaussianDistribution
extends java.lang.Object

A Java implementation for the multivariate Gaussian distribution given mean and covariance.

Version:
1.0 Feb. 26th, 2013
Author:
Mingjie Qian

Constructor Summary
MultivariateGaussianDistribution()
           
 
Method Summary
static void main(java.lang.String[] args)
           
static org.apache.commons.math.linear.RealMatrix mvnrnd(double[] MU, double[][] SIGMA, int cases)
          Generate random samples chosen from the multivariate Gaussian distribution with mean MU and covariance SIGMA.
static org.apache.commons.math.linear.RealMatrix mvnrnd(double[] MU, double[] SIGMA, int cases)
          Generate random samples chosen from the multivariate Gaussian distribution with mean MU and a diagonal covariance SIGMA.
static org.apache.commons.math.linear.RealMatrix mvnrnd(org.apache.commons.math.linear.RealMatrix MU, org.apache.commons.math.linear.RealMatrix SIGMA, int cases)
          Generate random samples chosen from the multivariate Gaussian distribution with mean MU and covariance SIGMA.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultivariateGaussianDistribution

public MultivariateGaussianDistribution()
Method Detail

main

public static void main(java.lang.String[] args)
Parameters:
args -

mvnrnd

public static org.apache.commons.math.linear.RealMatrix mvnrnd(org.apache.commons.math.linear.RealMatrix MU,
                                                               org.apache.commons.math.linear.RealMatrix SIGMA,
                                                               int cases)
Generate random samples chosen from the multivariate Gaussian distribution with mean MU and covariance SIGMA. X ~ N(u, Lambda) => Y = B * X + v ~ N(B * u + v, B * Lambda * B') Therefore, if X ~ N(0, Lambda), then Y = B * X + MU ~ N(MU, B * Lambda * B'). We only need to do the eigen decomposition: SIGMA = B * Lambda * B'.

Parameters:
MU - 1 x d mean vector
SIGMA - covariance matrix
cases - number of d dimensional random samples
Returns:
cases-by-d sample matrix subject to the multivariate Gaussian distribution N(MU, SIGMA)

mvnrnd

public static org.apache.commons.math.linear.RealMatrix mvnrnd(double[] MU,
                                                               double[][] SIGMA,
                                                               int cases)
Generate random samples chosen from the multivariate Gaussian distribution with mean MU and covariance SIGMA. X ~ N(u, Lambda) => Y = B * X + v ~ N(B * u + v, B * Lambda * B') Therefore, if X ~ N(0, Lambda), then Y = B * X + MU ~ N(MU, B * Lambda * B'). We only need to do the eigen decomposition: SIGMA = B * Lambda * B'.

Parameters:
MU - a 1D double array holding the mean vector
SIGMA - a 2D double array holding the covariance matrix
cases - number of d dimensional random samples
Returns:
cases-by-d sample matrix subject to the multivariate Gaussian distribution N(MU, SIGMA)

mvnrnd

public static org.apache.commons.math.linear.RealMatrix mvnrnd(double[] MU,
                                                               double[] SIGMA,
                                                               int cases)
Generate random samples chosen from the multivariate Gaussian distribution with mean MU and a diagonal covariance SIGMA. X ~ N(u, Lambda) => Y = B * X + v ~ N(B * u + v, B * Lambda * B') Therefore, if X ~ N(0, Lambda), then Y = B * X + MU ~ N(MU, B * Lambda * B'). We only need to do the eigen decomposition: SIGMA = B * Lambda * B'.

Parameters:
MU - a 1D double array holding the mean vector
SIGMA - a 1D double array holding the diagonal elements of the covariance matrix
cases - number of d dimensional random samples
Returns:
cases-by-d sample matrix subject to the multivariate Gaussian distribution N(MU, SIGMA)