2/07/2017

EM algorithm for GMM applied in Matlab

Today, I finished reading the paper and  found codes for fitting a Gaussian Mixture Model to data.

Summary:

Models in the paper:
Weibull distribution
Log-normal distribution
Generalized gamma distribution
Generalized F-distribution
Use a mixture of parametric distributions

A mixture of two gamma distributions

Codes:
options = statset('Display','final');
gm = fitgmdist((T2row1)',2,'Options',options);

ComponentMeans = gm.mu
ComponentCovariances = gm.Sigma
MixtureProportions = gm.PComponents

AIC = zeros(1,4);
gm = cell(1,4);
for k = 1:4
    gm{k} = fitgmdist(X,k);
    AIC(k)= gm{k}.AIC;
end

[minAIC,numComponents] = min(AIC);
numComponents

gm2 = gm{numComponents}

I applied the codes to the first row of NMR T2 distribution data and get the following results:

30 iterations, log-likelihood = 391.441

ComponentMeans =

    0.0002
    0.0018


ComponentCovariances(:,:,1) =

   4.7465e-08


ComponentCovariances(:,:,2) =

   3.3443e-07


MixtureProportions =

    0.6682    0.3318


numComponents =

     2


gm2 =

Gaussian mixture distribution with 2 components in 2 dimensions
Component 1:
Mixing proportion: 0.500000
Mean:   -3.0377   -4.9859

Component 2:
Mixing proportion: 0.500000
Mean:    0.9812    2.0563

There are only codes for plotting the contour figures instead of fitting codes.

Tomorrow, I will continue to learn how to plot fitting figures and improve the fitting results.

No comments:

Post a Comment