Package elki.clustering.em.models
Class MultivariateGaussianModel
- java.lang.Object
-
- elki.clustering.em.models.MultivariateGaussianModel
-
- All Implemented Interfaces:
BetulaClusterModel,EMClusterModel<elki.data.NumberVector,EMModel>
public class MultivariateGaussianModel extends java.lang.Object implements BetulaClusterModel
Model for a single multivariate Gaussian cluster with arbitrary rotation.- Since:
- 0.7.0
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description (package private) elki.math.linearalgebra.CholeskyDecompositioncholDecomposition of covariance matrix.(package private) double[][]covarianceCovariance matrix.private static elki.logging.LoggingLOGClass logger.(package private) doublelogNormNormalization factor.(package private) doublelogNormDetNormalization factor.(package private) double[]meanMean vector.(package private) double[]nmeaTemporary storage, to avoid reallocations.(package private) double[][]priormatrixMatrix for prior conditioning.private static doubleSINGULARITY_CHEATConstant to avoid singular matrixes.(package private) doubleweightWeight aggregation sum.(package private) doublewsumWeight aggregation sum.
-
Constructor Summary
Constructors Constructor Description MultivariateGaussianModel(double weight, double[] mean)Constructor.MultivariateGaussianModel(double weight, double[] mean, double[][] covariance)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginEStep()Begin the E step.doubleestimateLogDensity(elki.data.NumberVector vec)Estimate the log likelihood of a vector.doubleestimateLogDensity(ClusterFeature cf)Estimate the log likelihood of a clustering feature.EMModelfinalizeCluster()Finalize a cluster model.voidfinalizeEStep(double weight, double prior)Finalize the E step.protected static doublegetHalfLogDeterminant(elki.math.linearalgebra.CholeskyDecomposition chol)Get 0.5 * log(det) of a cholesky decomposition.doublegetWeight()Get the cluster weight.doublemahalanobisDistance(double[] vec)Compute the Mahalanobis distance from the centroid for a given vector.doublemahalanobisDistance(elki.data.NumberVector vec)Compute the Mahalanobis distance from the centroid for a given vector.voidsetWeight(double weight)Set the cluster weight.protected static elki.math.linearalgebra.CholeskyDecompositionupdateCholesky(double[][] covariance, elki.math.linearalgebra.CholeskyDecomposition prev)Update the cholesky decomposition.voidupdateE(elki.data.NumberVector vec, double wei)Process one data point in the E stepvoidupdateE(ClusterFeature cf, double wei)Process one clustering feature in the E step.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.clustering.em.models.EMClusterModel
finalizeFirstPassE, firstPassE, needsTwoPass
-
-
-
-
Field Detail
-
LOG
private static final elki.logging.Logging LOG
Class logger.
-
SINGULARITY_CHEAT
private static final double SINGULARITY_CHEAT
Constant to avoid singular matrixes.- See Also:
- Constant Field Values
-
mean
double[] mean
Mean vector.
-
covariance
double[][] covariance
Covariance matrix.
-
chol
elki.math.linearalgebra.CholeskyDecomposition chol
Decomposition of covariance matrix.
-
nmea
double[] nmea
Temporary storage, to avoid reallocations.
-
logNorm
double logNorm
Normalization factor.
-
logNormDet
double logNormDet
Normalization factor.
-
weight
double weight
Weight aggregation sum.
-
wsum
double wsum
Weight aggregation sum.
-
priormatrix
double[][] priormatrix
Matrix for prior conditioning.
-
-
Constructor Detail
-
MultivariateGaussianModel
public MultivariateGaussianModel(double weight, double[] mean)Constructor.- Parameters:
weight- Cluster weightmean- Initial mean
-
MultivariateGaussianModel
public MultivariateGaussianModel(double weight, double[] mean, double[][] covariance)Constructor.- Parameters:
weight- Cluster weightmean- Initial meancovariance- Initial covariance matrix
-
-
Method Detail
-
beginEStep
public void beginEStep()
Description copied from interface:EMClusterModelBegin the E step.- Specified by:
beginEStepin interfaceEMClusterModel<elki.data.NumberVector,EMModel>
-
updateE
public void updateE(elki.data.NumberVector vec, double wei)Description copied from interface:EMClusterModelProcess one data point in the E step- Specified by:
updateEin interfaceEMClusterModel<elki.data.NumberVector,EMModel>- Parameters:
vec- Vector to processwei- Weight of point ("responsibility" of the cluster)
-
finalizeEStep
public void finalizeEStep(double weight, double prior)Description copied from interface:EMClusterModelFinalize the E step.- Specified by:
finalizeEStepin interfaceEMClusterModel<elki.data.NumberVector,EMModel>- Parameters:
weight- weight of the clusterprior- MAP prior (0 for MLE)
-
updateCholesky
protected static elki.math.linearalgebra.CholeskyDecomposition updateCholesky(double[][] covariance, elki.math.linearalgebra.CholeskyDecomposition prev)Update the cholesky decomposition.- Parameters:
covariance- Covariance matrixprev- Previous Cholesky decomposition (reused in case of instability)- Returns:
- New Cholesky decomposition
-
getHalfLogDeterminant
protected static double getHalfLogDeterminant(elki.math.linearalgebra.CholeskyDecomposition chol)
Get 0.5 * log(det) of a cholesky decomposition.- Parameters:
chol- Cholesky Decomposition- Returns:
- log determinant.
-
mahalanobisDistance
public double mahalanobisDistance(double[] vec)
Compute the Mahalanobis distance from the centroid for a given vector.- Parameters:
vec- Vector- Returns:
- Mahalanobis distance
-
mahalanobisDistance
public double mahalanobisDistance(elki.data.NumberVector vec)
Compute the Mahalanobis distance from the centroid for a given vector.Note: used by P3C.
- Parameters:
vec- Vector- Returns:
- Mahalanobis distance
-
estimateLogDensity
public double estimateLogDensity(elki.data.NumberVector vec)
Description copied from interface:EMClusterModelEstimate the log likelihood of a vector.- Specified by:
estimateLogDensityin interfaceEMClusterModel<elki.data.NumberVector,EMModel>- Parameters:
vec- Vector- Returns:
- log likelihood.
-
getWeight
public double getWeight()
Description copied from interface:EMClusterModelGet the cluster weight.- Specified by:
getWeightin interfaceEMClusterModel<elki.data.NumberVector,EMModel>- Returns:
- Cluster weight
-
setWeight
public void setWeight(double weight)
Description copied from interface:EMClusterModelSet the cluster weight.- Specified by:
setWeightin interfaceEMClusterModel<elki.data.NumberVector,EMModel>- Parameters:
weight- Cluster weight
-
finalizeCluster
public EMModel finalizeCluster()
Description copied from interface:EMClusterModelFinalize a cluster model.- Specified by:
finalizeClusterin interfaceEMClusterModel<elki.data.NumberVector,EMModel>- Returns:
- Cluster model
-
estimateLogDensity
public double estimateLogDensity(ClusterFeature cf)
Description copied from interface:BetulaClusterModelEstimate the log likelihood of a clustering feature.- Specified by:
estimateLogDensityin interfaceBetulaClusterModel- Parameters:
cf- ClusteringFeature- Returns:
- log likelihood
-
updateE
public void updateE(ClusterFeature cf, double wei)
Description copied from interface:BetulaClusterModelProcess one clustering feature in the E step.- Specified by:
updateEin interfaceBetulaClusterModel- Parameters:
cf- Clustering feature to process.wei- weight of the clustering feature.
-
-