Class TextbookMultivariateGaussianModel

  • All Implemented Interfaces:
    EMClusterModel<NumberVector,​EMModel>

    public class TextbookMultivariateGaussianModel
    extends java.lang.Object
    implements EMClusterModel<NumberVector,​EMModel>
    Numerically problematic implementation of the GMM model, using the textbook algorithm. There is no reason to use this in practice, it is only useful to study the reliability of the textbook approach.

    "Textbook" refers to the E[XY]-E[X]E[Y] equation for covariance, that is numerically not reliable with floating point math, but popular in textbooks.

    Again, do not use this. Always prefer MultivariateGaussianModel.

    Since:
    0.7.5
    Author:
    Erich Schubert
    • Field Detail

      • mean

        double[] mean
        Mean vector.
      • covariance

        double[][] covariance
        Covariance matrix.
      • tmp

        double[] tmp
        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

      • TextbookMultivariateGaussianModel

        public TextbookMultivariateGaussianModel​(double weight,
                                                 double[] mean)
        Constructor.
        Parameters:
        weight - Cluster weight
        mean - Initial mean
      • TextbookMultivariateGaussianModel

        public TextbookMultivariateGaussianModel​(double weight,
                                                 double[] mean,
                                                 double[][] covariance)
        Constructor.
        Parameters:
        weight - Cluster weight
        mean - Initial mean
        covariance - initial covariance matrix
    • Method Detail

      • updateE

        public void updateE​(double[] vec,
                            double[][] covm,
                            double sca,
                            double wei)
        Add a set of points with covariance information, for KDTreeEM.
        Parameters:
        vec - sum of new points
        covm - sum of codeviates
        sca - scaling factor applied to vec and covm instead of wei
        wei - weight sum contribution
      • finalizeEStep

        public void finalizeEStep​(double weight,
                                  double prior)
        Description copied from interface: EMClusterModel
        Finalize the E step.
        Specified by:
        finalizeEStep in interface EMClusterModel<NumberVector,​EMModel>
        Parameters:
        weight - weight of the cluster
        prior - MAP prior (0 for MLE)
      • mahalanobisDistance

        public double mahalanobisDistance​(NumberVector vec)
        Compute the Mahalanobis distance from the centroid for a given vector.
        Parameters:
        vec - Vector
        Returns:
        Mahalanobis distance
      • calculateModelLimits

        public void calculateModelLimits​(double[] min,
                                         double[] max,
                                         ConstrainedQuadraticProblemSolver solver,
                                         double ipiPow,
                                         double[] minpnt,
                                         double[] maxpnt,
                                         double[] ret)
        Compute the weight of a Gaussian with respect to a bounding box.
        Parameters:
        min - Bounding box min will be modified
        max - Bounding box max will be modified
        solver - Quadratic solver
        ipiPow - scaling constant
        minpnt - result array for argmin
        maxpnt - result array for argmax
        ret - Return array