📄 runme.m
字号:
% Number of points
N = 300;
% Number of mixture components
K = 3;
% Number of dimensions
D = 2;
% Generate random points from a mixture
[x, pTrue, mTrue, sigmaTrue, classTrue] = makeClusters(N, K, D);
% Assuming that the true value of K is known
K = K;
% See kmeans.m for other calling options
[mKM, classKM, niterKM] = kmeans(x, K);
% See emi.m and em.m for other calling options
[pEM, mEM, sigmaEM, pknEM, niterEM] = emi(x, K);
[dummy, classEM] = colmax(pknEM);
% Display
figure(1)
showClusters(x, mTrue, classTrue);
title('True Clusters')
figure(2)
showClusters(x, mKM, classKM);
if niterKM < 0
iterKM = 'Max Number of';
else
iterKM = sprintf('%d', niterKM);
end
title(sprintf('Clusters from %s Iterations of K Means', iterKM))
figure(3)
showClusters(x, mEM, classEM);
if niterEM < 0
iterEM = 'Max Number of';
else
iterEM = sprintf('%d', niterEM);
end
title(sprintf('Clusters Inferred from EM Probabilities (%s Iterations)', iterEM))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -