This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

gmdistribution class

Gaussian mixture models


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.


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


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

ComponentProportionInput vector of mixing proportions
CovarianceTypeType of covariance matrices
DistributionNameType of distribution
muInput matrix of means mu
NumComponentsNumber k of mixture components
NumVariablesDimension d of multivariate Gaussian distributions
ProbabilityToleranceTolerance for posterior probabilities
SharedCovariancetrue 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
NegativeLogLikelihoodNegative of log-likelihood
NumIterationsNumber of iterations
RegularizationValueValue of 'Regularize' parameter


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 (MATLAB) in the MATLAB® documentation.


expand all

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

Generate the data using 1000 points from each distribution.

rng(1); % For reproducibility
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)];

hold on

Fit a two-component Gaussian mixture model.

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

Plot the fit.

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


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

Was this topic helpful?