Package elki.clustering.em.models
Class DiagonalGaussianModel
- java.lang.Object
-
- elki.clustering.em.models.DiagonalGaussianModel
-
- All Implemented Interfaces:
BetulaClusterModel
,EMClusterModel<NumberVector,EMModel>
public class DiagonalGaussianModel extends java.lang.Object implements BetulaClusterModel
Simpler model for a single Gaussian cluster, without covariances.- Since:
- 0.7.0
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description (package private) double
logNorm
Normalization factor.(package private) double
logNormDet
Normalization factor.(package private) double[]
mean
Mean vector.(package private) double[]
nmea
Temporary storage, to avoid reallocations.(package private) double[]
priordiag
Diagonal prior variances.private static double
SINGULARITY_CHEAT
Constant to avoid zero values.(package private) double[]
variances
Per-dimension variances.(package private) double
weight
Weight aggregation sum.(package private) double
wsum
Weight aggregation sum.
-
Constructor Summary
Constructors Constructor Description DiagonalGaussianModel(double weight, double[] mean)
Constructor.DiagonalGaussianModel(double weight, double[] mean, double[] vars)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginEStep()
Begin the E step.double
estimateLogDensity(NumberVector vec)
Estimate the log likelihood of a vector.double
estimateLogDensity(ClusterFeature cf)
Estimate the log likelihood of a clustering feature.EMModel
finalizeCluster()
Finalize a cluster model.void
finalizeEStep(double weight, double prior)
Finalize the E step.double
getWeight()
Get the cluster weight.double
mahalanobisDistance(double[] vec)
Compute the Mahalanobis distance from the centroid for a given vector.double
mahalanobisDistance(NumberVector vec)
Compute the Mahalanobis distance from the centroid for a given vector.void
setWeight(double weight)
Set the cluster weight.void
updateE(NumberVector vec, double wei)
Process one data point in the E stepvoid
updateE(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
-
SINGULARITY_CHEAT
private static final double SINGULARITY_CHEAT
Constant to avoid zero values.- See Also:
- Constant Field Values
-
mean
double[] mean
Mean vector.
-
variances
double[] variances
Per-dimension variances.
-
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.
-
priordiag
double[] priordiag
Diagonal prior variances.
-
-
Constructor Detail
-
DiagonalGaussianModel
public DiagonalGaussianModel(double weight, double[] mean)
Constructor.- Parameters:
weight
- Cluster weightmean
- Initial mean
-
DiagonalGaussianModel
public DiagonalGaussianModel(double weight, double[] mean, double[] vars)
Constructor.- Parameters:
weight
- Cluster weightmean
- Initial meanvars
- Initial variances
-
-
Method Detail
-
beginEStep
public void beginEStep()
Description copied from interface:EMClusterModel
Begin the E step.- Specified by:
beginEStep
in interfaceEMClusterModel<NumberVector,EMModel>
-
updateE
public void updateE(NumberVector vec, double wei)
Description copied from interface:EMClusterModel
Process one data point in the E step- Specified by:
updateE
in interfaceEMClusterModel<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:EMClusterModel
Finalize the E step.- Specified by:
finalizeEStep
in interfaceEMClusterModel<NumberVector,EMModel>
- Parameters:
weight
- weight of the clusterprior
- MAP prior (0 for MLE)
-
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(NumberVector vec)
Compute the Mahalanobis distance from the centroid for a given vector.- Parameters:
vec
- Vector- Returns:
- Mahalanobis distance
-
estimateLogDensity
public double estimateLogDensity(NumberVector vec)
Description copied from interface:EMClusterModel
Estimate the log likelihood of a vector.- Specified by:
estimateLogDensity
in interfaceEMClusterModel<NumberVector,EMModel>
- Parameters:
vec
- Vector- Returns:
- log likelihood.
-
getWeight
public double getWeight()
Description copied from interface:EMClusterModel
Get the cluster weight.- Specified by:
getWeight
in interfaceEMClusterModel<NumberVector,EMModel>
- Returns:
- Cluster weight
-
setWeight
public void setWeight(double weight)
Description copied from interface:EMClusterModel
Set the cluster weight.- Specified by:
setWeight
in interfaceEMClusterModel<NumberVector,EMModel>
- Parameters:
weight
- Cluster weight
-
finalizeCluster
public EMModel finalizeCluster()
Description copied from interface:EMClusterModel
Finalize a cluster model.- Specified by:
finalizeCluster
in interfaceEMClusterModel<NumberVector,EMModel>
- Returns:
- Cluster model
-
estimateLogDensity
public double estimateLogDensity(ClusterFeature cf)
Description copied from interface:BetulaClusterModel
Estimate the log likelihood of a clustering feature.- Specified by:
estimateLogDensity
in interfaceBetulaClusterModel
- Parameters:
cf
- ClusteringFeature- Returns:
- log likelihood
-
updateE
public void updateE(ClusterFeature cf, double wei)
Description copied from interface:BetulaClusterModel
Process one clustering feature in the E step.- Specified by:
updateE
in interfaceBetulaClusterModel
- Parameters:
cf
- Clustering feature to process.wei
- weight of the clustering feature.
-
-