This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Create Gaussian Mixture Model

This example shows how to create a known, or fully specified, Gaussian mixture model (GMM) object using gmdistribution and by specifying component means, covariances, and mixture proportions. To create a GMM object by fitting data to a GMM, see Fit Gaussian Mixture Model to Data.

Specify the component means, covariances, and mixing proportions for a two-component mixture of bivariate Gaussian distributions.

mu = [1 2;-3 -5];                    % Means
sigma = cat(3,[2 0;0 .5],[1 0;0 1]); % Covariances
p = ones(1,2)/2;                     % Mixing proportions

The rows of mu correspond to the component mean vectors, and the pages of sigma, sigma(:,;,J), correspond to the component covariance matrices.

Create a GMM object using gmdistribution.

gm = gmdistribution(mu,sigma,p);

Display the properties of the GMM.

properties(gm)
Properties for class gmdistribution:

    NumVariables
    DistributionName
    NumComponents
    ComponentProportion
    SharedCovariance
    NumIterations
    RegularizationValue
    NegativeLogLikelihood
    CovarianceType
    mu
    Sigma
    AIC
    BIC
    Converged
    ProbabilityTolerance

For a description of the properties, see gmdistribution. To access the value of a property, use dot notation. For example, access the number of variables of each GMM component.

dimension = gm.NumVariables
dimension = 2

Visualize the probability density function (pdf) of the GMM using pdf and the MATLAB® function fsurf.

gmPDF = @(x,y)reshape(pdf(gm,[x(:) y(:)]),size(x)); 
fsurf(gmPDF,[-10 10])
title('Probability Density Function of GMM');

Visualize the cumulative distribution function (cdf) of the GMM using cdf and fsurf.

gmCDF = @(x,y)reshape(cdf(gm,[x(:) y(:)]),size(x)); 
fsurf(gmCDF,[-10 10])
title('Cumulative Distribution Function of GMM');

See Also

|

Related Topics