gov.sandia.cognition.statistics.distribution
Class NormalInverseWishartDistribution

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.statistics.AbstractDistribution<Matrix>
          extended by gov.sandia.cognition.statistics.distribution.NormalInverseWishartDistribution
All Implemented Interfaces:
Vectorizable, ClosedFormComputableDistribution<Matrix>, ClosedFormDistribution<Matrix>, ComputableDistribution<Matrix>, Distribution<Matrix>, DistributionWithMean<Matrix>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
NormalInverseWishartDistribution.PDF

@PublicationReference(author="Stanley Sawyer",
                      title="Wishart Distributions and Inverse-Wishart Sampling",
                      type=Misc,
                      year=2007,
                      url="http://www.math.wustl.edu/~sawyer/hmhandouts/Wishart.pdf")
public class NormalInverseWishartDistribution
extends AbstractDistribution<Matrix>
implements ClosedFormComputableDistribution<Matrix>

The normal inverse Wishart distribution

Since:
3.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Nested Class Summary
static class NormalInverseWishartDistribution.PDF
          PDF of the normal inverse-Wishart distribution.
 
Field Summary
protected  double covarianceDivisor
          Term that divides the covariance sampled from the inverseWishart, must be greater than zero.
static double DEFAULT_COVARIANCE_DIVISOR
          Default covariance divisor, 1.0.
static int DEFAULT_DIMENSIONALITY
          Default dimensionality of the precision matrix, 2.
protected  MultivariateGaussian gaussian
          Generates the mean, given the covariance from the inverseWishart.
protected  InverseWishartDistribution inverseWishart
          Generates the covariance for the Gaussian.
 
Constructor Summary
NormalInverseWishartDistribution()
          Default constructor
NormalInverseWishartDistribution(int dimensionality)
          Creates a new instance of NormalInverseWishartDistribution
NormalInverseWishartDistribution(int dimensionality, double covarianceDivisor)
          Creates a new instance of NormalInverseWishartDistribution
NormalInverseWishartDistribution(MultivariateGaussian gaussian, InverseWishartDistribution inverseWishart, double covarianceDivisor)
          Creates a new instance of NormalInverseWishartDistribution
NormalInverseWishartDistribution(NormalInverseWishartDistribution other)
          Copy constructor
 
Method Summary
 NormalInverseWishartDistribution clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 void convertFromVector(Vector parameters)
          Converts the object from a Vector of parameters.
 Vector convertToVector()
          Converts the object to a vector.
 double getCovarianceDivisor()
          Getter for covarianceDivisor
 MultivariateGaussian getGaussian()
          Getter for gaussian.
 int getInputDimensionality()
          Gets the input dimensionality of the Gaussian and the inverse-Wishart distributions
 InverseWishartDistribution getInverseWishart()
          Getter for inverseWishart
 Matrix getMean()
          Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.
 NormalInverseWishartDistribution.PDF getProbabilityFunction()
          Gets the distribution function associated with this Distribution, either the PDF or PMF.
 ArrayList<Matrix> sample(Random random, int numSamples)
          Draws multiple random samples from the distribution.
 void setCovarianceDivisor(double covarianceDivisor)
          Setter for covarianceDivisor
 void setGaussian(MultivariateGaussian gaussian)
          Setter for gaussian
 void setInverseWishart(InverseWishartDistribution inverseWishart)
          Setter for inverseWishart
 
Methods inherited from class gov.sandia.cognition.statistics.AbstractDistribution
sample
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.statistics.Distribution
sample
 

Field Detail

DEFAULT_DIMENSIONALITY

public static final int DEFAULT_DIMENSIONALITY
Default dimensionality of the precision matrix, 2.

See Also:
Constant Field Values

DEFAULT_COVARIANCE_DIVISOR

public static final double DEFAULT_COVARIANCE_DIVISOR
Default covariance divisor, 1.0.

See Also:
Constant Field Values

covarianceDivisor

protected double covarianceDivisor
Term that divides the covariance sampled from the inverseWishart, must be greater than zero.


gaussian

protected MultivariateGaussian gaussian
Generates the mean, given the covariance from the inverseWishart.


inverseWishart

protected InverseWishartDistribution inverseWishart
Generates the covariance for the Gaussian.

Constructor Detail

NormalInverseWishartDistribution

public NormalInverseWishartDistribution()
Default constructor


NormalInverseWishartDistribution

public NormalInverseWishartDistribution(int dimensionality)
Creates a new instance of NormalInverseWishartDistribution

Parameters:
dimensionality - Dimensionality of the distributions

NormalInverseWishartDistribution

public NormalInverseWishartDistribution(int dimensionality,
                                        double covarianceDivisor)
Creates a new instance of NormalInverseWishartDistribution

Parameters:
dimensionality - Dimensionality of the distributions
covarianceDivisor - Term that divides the covariance sampled from the inverseWishart, must be greater than zero.

NormalInverseWishartDistribution

public NormalInverseWishartDistribution(MultivariateGaussian gaussian,
                                        InverseWishartDistribution inverseWishart,
                                        double covarianceDivisor)
Creates a new instance of NormalInverseWishartDistribution

Parameters:
gaussian - Generates the mean, given the covariance from the inverseWishart.
inverseWishart - Generates the covariance for the Gaussian.
covarianceDivisor - Term that divides the covariance sampled from the inverseWishart, must be greater than zero.

NormalInverseWishartDistribution

public NormalInverseWishartDistribution(NormalInverseWishartDistribution other)
Copy constructor

Parameters:
other - NormalInverseWishartDistribution to copy
Method Detail

clone

public NormalInverseWishartDistribution clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface Vectorizable
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

getGaussian

public MultivariateGaussian getGaussian()
Getter for gaussian.

Returns:
Generates the mean, given the covariance from the inverseWishart.

setGaussian

public void setGaussian(MultivariateGaussian gaussian)
Setter for gaussian

Parameters:
gaussian - Generates the mean, given the covariance from the inverseWishart.

getInverseWishart

public InverseWishartDistribution getInverseWishart()
Getter for inverseWishart

Returns:
Generates the covariance for the Gaussian.

setInverseWishart

public void setInverseWishart(InverseWishartDistribution inverseWishart)
Setter for inverseWishart

Parameters:
inverseWishart - Generates the covariance for the Gaussian.

getCovarianceDivisor

public double getCovarianceDivisor()
Getter for covarianceDivisor

Returns:
Term that divides the covariance sampled from the inverseWishart, must be greater than zero.

setCovarianceDivisor

public void setCovarianceDivisor(double covarianceDivisor)
Setter for covarianceDivisor

Parameters:
covarianceDivisor - Term that divides the covariance sampled from the inverseWishart, must be greater than zero.

getMean

public Matrix getMean()
Description copied from interface: DistributionWithMean
Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.

Specified by:
getMean in interface DistributionWithMean<Matrix>
Returns:
Mean of the distribution.

sample

public ArrayList<Matrix> sample(Random random,
                                int numSamples)
Description copied from interface: Distribution
Draws multiple random samples from the distribution. It is generally more efficient to use this multiple-sample method than multiple calls of the single-sample method. (But not always.)

Specified by:
sample in interface Distribution<Matrix>
Parameters:
random - Random-number generator to use in order to generate random numbers.
numSamples - Number of samples to draw from the distribution.
Returns:
Samples drawn according to this distribution.

convertToVector

public Vector convertToVector()
Description copied from interface: Vectorizable
Converts the object to a vector.

Specified by:
convertToVector in interface Vectorizable
Returns:
The Vector form of the object.

convertFromVector

public void convertFromVector(Vector parameters)
Description copied from interface: Vectorizable
Converts the object from a Vector of parameters.

Specified by:
convertFromVector in interface Vectorizable
Parameters:
parameters - The parameters to incorporate.

getInputDimensionality

public int getInputDimensionality()
Gets the input dimensionality of the Gaussian and the inverse-Wishart distributions

Returns:
Input dimensionality of the Gaussian and the inverse-Wishart distributions

getProbabilityFunction

public NormalInverseWishartDistribution.PDF getProbabilityFunction()
Description copied from interface: ComputableDistribution
Gets the distribution function associated with this Distribution, either the PDF or PMF.

Specified by:
getProbabilityFunction in interface ComputableDistribution<Matrix>
Returns:
Distribution function associated with this Distribution.