org.apache.mahout.math.random
Class MultiNormal

java.lang.Object
  extended by org.apache.mahout.math.random.MultiNormal
All Implemented Interfaces:
Sampler<Vector>

public class MultiNormal
extends Object
implements Sampler<Vector>

Samples from a multi-variate normal distribution.

This is done by sampling from several independent unit normal distributions to get a vector u. The sample value that is returned is then A u + m where A is derived from the covariance matrix and m is the mean of the result.

If \Sigma is the desired covariance matrix, then you can use any value of A such that A' A = \Sigma. The Cholesky decomposition can be used to compute A if \Sigma is positive definite. Slightly more expensive is to use the SVD U S V' = \Sigma and then set A = U \sqrt{S}. Useful special cases occur when \Sigma is diagonal so that A = \sqrt(\Sigma) or where \Sigma = r I. Another special case is where m = 0.


Constructor Summary
MultiNormal(double radius, Vector mean)
           
MultiNormal(int dimension)
           
MultiNormal(Matrix a, Vector mean)
          Constructs a sampler with non-trivial scale matrix and mean.
MultiNormal(Vector diagonal)
          Constructs a sampler with diagonal scale matrix.
MultiNormal(Vector diagonal, Vector mean)
          Constructs a sampler with diagonal scale matrix and (potentially) non-zero mean.
 
Method Summary
 Vector getScale()
           
 Vector sample()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiNormal

public MultiNormal(Vector diagonal)
Constructs a sampler with diagonal scale matrix.

Parameters:
diagonal - The diagonal elements of the scale matrix.

MultiNormal

public MultiNormal(Vector diagonal,
                   Vector mean)
Constructs a sampler with diagonal scale matrix and (potentially) non-zero mean.

Parameters:
diagonal - The scale matrix's principal diagonal.
mean - The desired mean. Set to null if zero mean is desired.

MultiNormal

public MultiNormal(Matrix a,
                   Vector mean)
Constructs a sampler with non-trivial scale matrix and mean.


MultiNormal

public MultiNormal(int dimension)

MultiNormal

public MultiNormal(double radius,
                   Vector mean)
Method Detail

sample

public Vector sample()
Specified by:
sample in interface Sampler<Vector>

getScale

public Vector getScale()


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.