Jan 18, 2012

Fitting gaussian mixture model to the data

Here I have generated a mixture distribution using two gaussians: 1) Mean=3, Variance=1, 2) Mean=10, Variance=2, respectively. Then fit the mixture distribution using Matlab's gmdistribution.fit(), which estimates the mixture model parameters using Expectation Maximization algorithm.

MU1 = [3];
SIGMA1 = [1];
MU2 = [10];
SIGMA2 = [2];
X = [mvnrnd(MU1,SIGMA1,100);
mvnrnd(MU2,SIGMA2,100)];
% scatter(X(:,1),X(:,2),10,'.')
figure hist(X) title('histogram')
pause;
close;
options = statset('Display','final');
obj = gmdistribution.fit(X,2,'Options',options);
ComponentMeans = obj.mu
ComponentCovariances = obj.Sigma


Reference from Mathworks Matlab

No comments:

Down with the Dictatorship!

    "Let them hate me, so that they fear me" - Caligula 41AD