Documentation Center

  • Trial Software
  • Product Updates

gmdistribution class

Gaussian mixture models

Description

An object of the gmdistribution class defines a Gaussian mixture distribution, which is a multivariate distribution that consists of a mixture of one or more multivariate Gaussian distribution components. The number of components for a given gmdistribution object is fixed. Each multivariate Gaussian component is defined by its mean and covariance, and the mixture is defined by a vector of mixing proportions.

Construction

To create a Gaussian mixture distribution by specifying the distribution parameters, use the gmdistribution constructor. To fit a Gaussian mixture distribution model to data, use fitgmdist.

fitGaussian mixture parameter estimates
gmdistributionConstruct Gaussian mixture distribution

Properties

All objects of the class have the properties listed in the following table.

CovTypeType of covariance matrices
DistNameType of distribution
muInput matrix of means mu
NComponentsNumber k of mixture components
NDimensionsDimension d of multivariate Gaussian distributions
PComponentsInput vector of mixing proportions
SharedCovtrue if all covariance matrices are restricted to be the same
SigmaInput array of covariances

Objects constructed with fitgmdist have the additional properties listed in the following table.

AICAkaike Information Criterion
BICBayes Information Criterion
ConvergedDetermine if algorithm converged
ItersNumber of iterations
NlogLNegative of log-likelihood
RegVValue of 'Regularize' parameter

Methods

cdfCumulative distribution function for Gaussian mixture distribution
clusterConstruct clusters from Gaussian mixture distribution
dispDisplay Gaussian mixture distribution object
displayDisplay Gaussian mixture distribution object
fitGaussian mixture parameter estimates
mahalMahalanobis distance to component means
pdfProbability density function for Gaussian mixture distribution
posteriorPosterior probabilities of components
randomRandom numbers from Gaussian mixture distribution
subsasgnSubscripted reference for Gaussian mixture distribution object
subsrefSubscripted reference for Gaussian mixture distribution object

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.

Examples

expand all

Fit a Gaussian Mixture Model

Generate data from a mixture of two bivariate Gaussian distributions using the mvnrnd function. Fit the resulting data.

Generate the data using 1000 points from each distribution.

MU1 = [1 2];
SIGMA1 = [2 0; 0 .5];
MU2 = [-3 -5];
SIGMA2 = [1 0; 0 1];
X = [mvnrnd(MU1,SIGMA1,1000);mvnrnd(MU2,SIGMA2,1000)];

scatter(X(:,1),X(:,2),10,'.')
hold on

Fit a two-component Gaussian mixture model.

options = statset('Display','final');
obj = fitgmdist(X,2,'Options',options);
18 iterations, log-likelihood = -7058.35

Plot the fit.

h = ezcontour(@(x,y)pdf(obj,[x y]),[-8 6],[-8 6]);

References

[1] McLachlan, G., and D. Peel. Finite Mixture Models. Hoboken, NJ: John Wiley & Sons, Inc., 2000.

See Also

Was this topic helpful?