gov.sandia.cognition.statistics.distribution
Class InverseWishartDistribution

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.InverseWishartDistribution
All Implemented Interfaces:
Vectorizable, ClosedFormComputableDistribution<Matrix>, ClosedFormDistribution<Matrix>, ComputableDistribution<Matrix>, Distribution<Matrix>, DistributionWithMean<Matrix>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
InverseWishartDistribution.PDF

@PublicationReferences(references={@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"),@PublicationReference(author="Wikipedia",title="Inverse-Wishart distribution",type=WebPage,year=2010,url="http://en.wikipedia.org/wiki/Inverse-Wishart_distribution")})
public class InverseWishartDistribution
extends AbstractDistribution<Matrix>
implements ClosedFormComputableDistribution<Matrix>

The Inverse-Wishart distribution is the multivariate generalization of the inverse-gamma distribution. This is the conjugate prior of a multivariate Gaussian with known mean and unknown covariance matrix. The Inverse-Wishart distribution describes a distribution over covariance matrices, where the matrices are computed by summing over "degrees of freedom" number of rank-1 outer-product matrices generated from a multivariate Gaussian distribution with a covariance equal to the inverse of the inverseScale matrix.

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

Nested Class Summary
static class InverseWishartDistribution.MultivariateGammaFunction
          Multivariate generalization of the Gamma function.
static class InverseWishartDistribution.PDF
          PDF of the Inverse-Wishart distribution, though I have absolutely no idea why anybody would evaluate the PDF of an Inverse-Wishart...
 
Field Summary
static int DEFAULT_DIMENSIONALITY
          Default inverse scale dimensionality, 2.
protected  int degreesOfFreedom
          Degrees of freedom, must be greater than the inverse scale dimensionality.
protected  Matrix inverseScale
          Inverse scale matrix, must be symmetric and positive definite.
 
Constructor Summary
InverseWishartDistribution()
          Creates a new instance of InverseWishartDistribution
InverseWishartDistribution(int dimensionality)
          Creates a new instance of InverseWishartDistribution
InverseWishartDistribution(InverseWishartDistribution other)
          Copy constructor.
InverseWishartDistribution(Matrix inverseScale, int degreesOfFreedom)
          Creates a new instance of InverseWishartDistribution
 
Method Summary
 InverseWishartDistribution 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.
 int getDegreesOfFreedom()
          Getter for degreesOfFreedom
 int getInputDimensionality()
          Gets the dimensionality of the inverse scale Matrix.
 Matrix getInverseScale()
          Getter for inverseScale
 Matrix getMean()
          Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.
 InverseWishartDistribution.PDF getProbabilityFunction()
          Gets the distribution function associated with this Distribution, either the PDF or PMF.
 Matrix getScaleSqrt()
          Getter for scaleSqrt
 ArrayList<Matrix> sample(Random random, int numSamples)
          Draws multiple random samples from the distribution.
static Matrix sample(Random random, Vector mean, Matrix covarianceSqrt, int degreesOfFreedom)
          Creates a single sample covariance matrix inverse from the given parameters.
 void setDegreesOfFreedom(int degreesOfFreedom)
          Setter for degreesOfFreedom
 void setInverseScale(Matrix inverseScale)
          Setter for inverseScale
 
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 inverse scale dimensionality, 2.

See Also:
Constant Field Values

inverseScale

protected Matrix inverseScale
Inverse scale matrix, must be symmetric and positive definite.


degreesOfFreedom

protected int degreesOfFreedom
Degrees of freedom, must be greater than the inverse scale dimensionality.

Constructor Detail

InverseWishartDistribution

public InverseWishartDistribution()
Creates a new instance of InverseWishartDistribution


InverseWishartDistribution

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

Parameters:
dimensionality - Dimensionality of the inverse-Wishart distribution, which sets the degrees of freedom to two plus the dimensionality.

InverseWishartDistribution

public InverseWishartDistribution(Matrix inverseScale,
                                  int degreesOfFreedom)
Creates a new instance of InverseWishartDistribution

Parameters:
inverseScale - Inverse scale matrix, must be symmetric and positive definite.
degreesOfFreedom - Degrees of freedom, must be greater than the inverse scale dimensionality.

InverseWishartDistribution

public InverseWishartDistribution(InverseWishartDistribution other)
Copy constructor.

Parameters:
other - InverseWishartDistribution to copy
Method Detail

clone

public InverseWishartDistribution 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.

getInputDimensionality

public int getInputDimensionality()
Gets the dimensionality of the inverse scale Matrix.

Returns:
Dimensionality of the inverse scale Matrix

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 static Matrix sample(Random random,
                            Vector mean,
                            Matrix covarianceSqrt,
                            int degreesOfFreedom)
Creates a single sample covariance matrix inverse from the given parameters.

Parameters:
random - Random number generator.
mean - Vector of zeros with the same dimensionality as covarianceSqrt
covarianceSqrt - Square root of the covariance matrix, and the covariance matrix is the inverse of the inverseScale matrix.
degreesOfFreedom - Number of rank-1 matrices to add up for each sample.
Returns:
Covariance matrix inverse.

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.

getInverseScale

public Matrix getInverseScale()
Getter for inverseScale

Returns:
Inverse scale matrix, must be symmetric and positive definite.

setInverseScale

public void setInverseScale(Matrix inverseScale)
Setter for inverseScale

Parameters:
inverseScale - Inverse scale matrix, must be symmetric and positive definite.

getDegreesOfFreedom

public int getDegreesOfFreedom()
Getter for degreesOfFreedom

Returns:
Degrees of freedom, must be greater than the inverse scale dimensionality.

setDegreesOfFreedom

public void setDegreesOfFreedom(int degreesOfFreedom)
Setter for degreesOfFreedom

Parameters:
degreesOfFreedom - Degrees of freedom, must be greater than the inverse scale dimensionality.

getProbabilityFunction

public InverseWishartDistribution.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.

getScaleSqrt

public Matrix getScaleSqrt()
Getter for scaleSqrt

Returns:
Cached value of the square root of the inverse of the inverseScale, used for sampling.