@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>
Modifier and Type | Class and Description |
---|---|
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...
|
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
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
|
static Matrix |
sample(java.util.Random random,
Vector mean,
Matrix covarianceSqrt,
int degreesOfFreedom)
Creates a single sample covariance matrix inverse from the given
parameters.
|
void |
sampleInto(java.util.Random random,
int sampleCount,
java.util.Collection<? super Matrix> output)
Draws multiple random samples from the distribution and puts the result
into the given collection.
|
void |
setDegreesOfFreedom(int degreesOfFreedom)
Setter for degreesOfFreedom
|
void |
setInverseScale(Matrix inverseScale)
Setter for inverseScale
|
sample, sample
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
sample, sample
public static final int DEFAULT_DIMENSIONALITY
protected Matrix inverseScale
protected int degreesOfFreedom
public InverseWishartDistribution()
public InverseWishartDistribution(int dimensionality)
dimensionality
- Dimensionality of the inverse-Wishart distribution, which sets
the degrees of freedom to two plus the dimensionality.public InverseWishartDistribution(Matrix inverseScale, int degreesOfFreedom)
inverseScale
- Inverse scale matrix, must be symmetric and positive definite.degreesOfFreedom
- Degrees of freedom, must be greater than the inverse scale
dimensionality.public InverseWishartDistribution(InverseWishartDistribution other)
other
- InverseWishartDistribution to copypublic InverseWishartDistribution clone()
AbstractCloneableSerializable
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.clone
in interface Vectorizable
clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public int getInputDimensionality()
public Matrix getMean()
DistributionWithMean
getMean
in interface DistributionWithMean<Matrix>
public static Matrix sample(java.util.Random random, Vector mean, Matrix covarianceSqrt, int degreesOfFreedom)
random
- Random number generator.mean
- Vector of zeros with the same dimensionality as covarianceSqrtcovarianceSqrt
- 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.public void sampleInto(java.util.Random random, int sampleCount, java.util.Collection<? super Matrix> output)
Distribution
sampleInto
in interface Distribution<Matrix>
random
- Random number generator to use.sampleCount
- The number of samples to draw. Cannot be negative.output
- The collection to add the samples into.public Vector convertToVector()
Vectorizable
convertToVector
in interface Vectorizable
public void convertFromVector(Vector parameters)
Vectorizable
convertFromVector
in interface Vectorizable
parameters
- The parameters to incorporate.public Matrix getInverseScale()
public void setInverseScale(Matrix inverseScale)
inverseScale
- Inverse scale matrix, must be symmetric and positive definite.public int getDegreesOfFreedom()
public void setDegreesOfFreedom(int degreesOfFreedom)
degreesOfFreedom
- Degrees of freedom, must be greater than the inverse scale
dimensionality.public InverseWishartDistribution.PDF getProbabilityFunction()
ComputableDistribution
getProbabilityFunction
in interface ComputableDistribution<Matrix>
public Matrix getScaleSqrt()