initclusters.m
来自「duke的tutorial on EM的matlab经典源码」· M 代码 · 共 30 行
M
30 行
% Find K points (columns of m) somewhere in the cloud of the points formed
% by the columns of x.
% If so requested also find K equal standard deviations that are reasonable
% starting values for k-means or EM.
% If so requested, also give K mixing probabilities, all equal to 1/K.
function [m, sigma, p] = initClusters(x, K)
D = size(x, 1);
% Centroid of all the data points
m = colmean(x')';
% Standard deviation in each dimension
sigma = colstd(x')';
oK = ones(1, K);
% K initial means somewhere within the cloud of data points
m = m * oK + (sigma * oK) .* randn(D, K);
if nargout >= 2
% K standard deviations
sigma = sqrt(sum(sigma .^ 2)) * oK / (K ^ (1/D));
end
if nargout >= 3
% K initial mixing probabilities
p = oK / K;
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?