聚类

1. 基于距离的迭代聚类

k-means 一个matlab实现: from: http://www.newsmth.net/nForum/article/AI/86245?p=1

function label = litekmeans(X, k)
n = size(X,2);
last = 0;
label = ceil(k*rand(1,n));  % random initialization
while any(label ~= last)
    [~,~,label] = unique(label);   % remove empty clusters
    E = sparse(1:n,label,1,n,k,n);  % transform label into indicator matrix
    center = X*(E*spdiags(1./sum(E,1)',0,k,k));    % compute center of each cluster
    last = label;
    [~,label] = max(bsxfun(@minus,center'*X,0.5*sum(center.^2,1)'),[],1); % assign samples to the nearest centers
end

2. 快速距离计算: KD树和球树


你可能感兴趣的:(function,matlab,Random,each,Matrix)