|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cc.mallet.util.MVNormal
public class MVNormal
Tools for working with multivariate normal distributions
Constructor Summary | |
---|---|
MVNormal()
|
Method Summary | |
---|---|
static double[] |
bandCholesky(double[] input,
int numRows)
|
static double[] |
bandMatrixRoot(int dim,
int bandwidth)
For testing band cholesky factorization |
static double[] |
cholesky(double[] input,
int numRows)
Simple Cholesky decomposition, with no checks on squareness, symmetricality, or positive definiteness. |
static java.lang.String |
diagonalToString(double[] matrix,
int dimension)
|
static java.lang.String |
doubleArrayToString(double[] matrix,
int dimension)
Create a string representation of a square matrix in one-dimensional array format |
static double[] |
getScatterMatrix(double[][] observationMatrix)
|
static double[] |
invertLowerTriangular(double[] inputMatrix,
int dimension)
This method returns the (lower-triangular) inverse of a lower triangular matrix. |
static double[] |
invertSPD(double[] inputMatrix,
int dimension)
|
static double[] |
lowerTriangularCrossproduct(double[] inputMatrix,
int dimension)
Returns L'L for lower triangular matrix L. |
static double[] |
lowerTriangularProduct(double[] leftMatrix,
double[] rightMatrix,
int dimension)
Returns (lower-triangular) X = AB for square lower-triangular matrices A and B |
static void |
main(java.lang.String[] args)
|
static FeatureVector |
nextFeatureVector(Alphabet alphabet,
double[] mean,
double[] precision,
Randoms random)
|
static double[] |
nextMVNormal(double[] mean,
double[] precision,
Randoms random)
Sample a multivariate normal from a precision matrix (ie inverse covariance matrix) |
static double[][] |
nextMVNormal(int n,
double[] mean,
double[] precision,
Randoms random)
|
static double[] |
nextMVNormalPosterior(double[] priorMean,
double[] priorPrecisionDiagonal,
double[] precision,
double[] observedMean,
int observations,
Randoms random)
|
static double[] |
nextMVNormalWithCholesky(double[] mean,
double[] precisionLowerTriangular,
Randoms random)
|
static double[] |
nextWishart(double[] sqrtScaleMatrix,
int dimension,
int degreesOfFreedom,
Randoms random)
A Wishart random variate, based on R code by Bill Venables. |
static double[] |
nextWishartPosterior(double[] scatterMatrix,
int observations,
double[] priorPrecisionDiagonal,
int priorDF,
int dimension,
Randoms random)
|
static double[] |
nextZeroSumMVNormalWithCholesky(double[] mean,
double[] precisionLowerTriangular,
Randoms random)
Sample a vector x from N(m, (LL')-1, such that sum_i x_i = 0. |
static double[] |
solveWithBackSubstitution(double[] b,
double[] lowerTriangular)
This method returns x such that L'x = b. |
static double[] |
solveWithForwardSubstitution(double[] b,
double[] lowerTriangular)
This method returns x such that Lx = b where L is lower triangular |
static void |
testCholesky()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MVNormal()
Method Detail |
---|
public static double[] cholesky(double[] input, int numRows)
Returns L such that LL' = A and L is lower-triangular.
public static double[] bandCholesky(double[] input, int numRows)
public static double[] bandMatrixRoot(int dim, int bandwidth)
public static double[] nextMVNormal(double[] mean, double[] precision, Randoms random)
public static double[] nextMVNormalWithCholesky(double[] mean, double[] precisionLowerTriangular, Randoms random)
public static double[] nextZeroSumMVNormalWithCholesky(double[] mean, double[] precisionLowerTriangular, Randoms random)
public static double[][] nextMVNormal(int n, double[] mean, double[] precision, Randoms random)
public static FeatureVector nextFeatureVector(Alphabet alphabet, double[] mean, double[] precision, Randoms random)
public static double[] nextMVNormalPosterior(double[] priorMean, double[] priorPrecisionDiagonal, double[] precision, double[] observedMean, int observations, Randoms random)
priorMean
- A vector of mean valuespriorPrecisionDiagonal
- A vector representing a diagonal prior precision matrixprecision
- A precision matrixpublic static double[] solveWithBackSubstitution(double[] b, double[] lowerTriangular)
public static double[] solveWithForwardSubstitution(double[] b, double[] lowerTriangular)
public static double[] invertLowerTriangular(double[] inputMatrix, int dimension)
public static double[] lowerTriangularCrossproduct(double[] inputMatrix, int dimension)
public static double[] lowerTriangularProduct(double[] leftMatrix, double[] rightMatrix, int dimension)
public static double[] invertSPD(double[] inputMatrix, int dimension)
public static double[] nextWishart(double[] sqrtScaleMatrix, int dimension, int degreesOfFreedom, Randoms random)
sqrtScaleMatrix
- The lower-triangular matrix square root of the scale matrix.
To draw from the posterior of a precision (ie inverse covariance) matrix,
this should be chol( S^{-1} ), where S is the scatter matrix X'X of
columns of MV normal observations X.dimension
- The size of the matrixdegreesOfFreedom
- The degree of freedom for the Wishart. Should be greater than dimension. For
a posterior distribution, this is the number of observations + the df of the prior.public static double[] nextWishartPosterior(double[] scatterMatrix, int observations, double[] priorPrecisionDiagonal, int priorDF, int dimension, Randoms random)
public static java.lang.String doubleArrayToString(double[] matrix, int dimension)
public static java.lang.String diagonalToString(double[] matrix, int dimension)
public static double[] getScatterMatrix(double[][] observationMatrix)
public static void testCholesky()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |