prea.util
Class Distribution

java.lang.Object
  extended by prea.util.Distribution

public class Distribution
extends java.lang.Object

This class implements several statistical distributions. Note that we use UJMP package (http://www.ujmp.org) to implement this class. Each distribution provides random sampling methods.

Since:
2012. 4. 20
Version:
1.1
Author:
Joonseok Lee

Constructor Summary
Distribution()
           
 
Method Summary
static double[] gammaDistribution(double alpha, double scale, int count)
          Randomly sample several points from Gamma Distribution with the given parameters.
static double gammaRandom(double alpha, double scale)
          Randomly sample 1 point from Gamma Distribution with the given parameters.
static double[] normalDistribution(double mean, double std, int count)
          Randomly sample several points from Normal Distribution with the given mean and standard deviation.
static double normalRandom(double mean, double std)
          Randomly sample 1 point from Normal Distribution with the given mean and standard deviation.
static SparseMatrix wishartRandom(SparseMatrix scale, double df)
          Randomly sample a matrix from Wishart Distribution with the given parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Distribution

public Distribution()
Method Detail

normalRandom

public static double normalRandom(double mean,
                                  double std)
Randomly sample 1 point from Normal Distribution with the given mean and standard deviation.

Parameters:
mean - Mean of this Normal Distribution.
std - Standard deviation of this Normal Distribution.
Returns:
The sample randomly drawn from the given distribution.

normalDistribution

public static double[] normalDistribution(double mean,
                                          double std,
                                          int count)
Randomly sample several points from Normal Distribution with the given mean and standard deviation.

Parameters:
mean - Mean of this Normal Distribution.
std - Standard deviation of this Normal Distribution.
count - The number of samples to draw.
Returns:
The sample randomly drawn from the given distribution.

gammaRandom

public static double gammaRandom(double alpha,
                                 double scale)
Randomly sample 1 point from Gamma Distribution with the given parameters. We use the code from Mahout (http://mahout.apache.org/), available under Apache 2 license.

Parameters:
alpha - Alpha parameter for Gamma Distribution.
scale - Scale parameter for Gamma Distribution.
Returns:
The sample randomly drawn from the given distribution.
Throws:
java.lang.IllegalArgumentException - if arguments are out of range.

gammaDistribution

public static double[] gammaDistribution(double alpha,
                                         double scale,
                                         int count)
Randomly sample several points from Gamma Distribution with the given parameters.

Parameters:
alpha - Alpha parameter for Gamma Distribution.
scale - Scale parameter for Gamma Distribution.
count - The number of samples to draw.
Returns:
The sample randomly drawn from the given distribution.

wishartRandom

public static SparseMatrix wishartRandom(SparseMatrix scale,
                                         double df)
Randomly sample a matrix from Wishart Distribution with the given parameters.

Parameters:
scale - Scale parameter for Wishart Distribution.
df - Degree of freedom for Wishart Distribution.
Returns:
The sample randomly drawn from the given distribution.