Regarding Gaussian mixture models
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I am trying to create a gaussian mixture model for the data attached here. Here is the piece of code I have written for my gray scale image attached herein the name matlab.m
X = mat_cell;num_dim=2;num_clus = 2; % number of mixtures/clusters
[counts,binLocations] = imhist(X);
stem(binLocations, counts, 'MarkerSize', 1 );
xlim([-1 1]);
% inital kmeans step used to initialize EM
rng('default');
data=reshape(X,[],num_dim);
[kmeanscid,cInd.mu] = kmeans(data, num_clus,'MaxIter', 75536);
data_k_1=data(kmeanscid==1);
data_k_2=data(kmeanscid==2);
a = diag(cov(data_k_1'));
b=diag(cov(data_k_2'));
if a==0
a=0.1;
elseif b==0
b=0.1;
end
initialsigma = cat(3,[a,a],[b,b]);
%disp(initialsigma);
cInd.Sigma=initialsigma;
% fit a GMM model
options = statset('MaxIter', 75536);
gmm = fitgmdist(data, num_clus,'Start',cInd,'CovarianceType','diagonal','Regularize',1e-5,'Options',options);
But the GMM is a single line and I am not sure whether i have done it right or wrong???
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!