⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clusterstats.m

📁 使用matlab进行实现的kmeans算法。数据集。
💻 M
字号:
function [nr,m,v] = clusterstats(x,c,K)% CLUSTERSTATS(x,c) computes the statistics for each cluster% [nr,m,v] = clusterstats(x,c[,K])%	x  - d*n matrix of samples%	c  - 1*n matrix with the cluster identity for each sample x(:,i)%	K  - the number of different clusters (max(c) if omitted)% returns%	nr - 1*K matrix with the number of samples in each cluster%	m  - d*K matrix with the mean for each cluster%	v  - d*K matrix with the variance for each component% Copyright (c) 1995-2001 Frank Dellaert% All rights Reservedif (nargin<3) K=max(c);end% get dimensions of data[d,n] = size(x);% allocate spacenr = zeros(1,K);sum = zeros(d,K);sumsq = zeros(d,K);% calculate statsfor i=1:K   ci=find(c==i);   nr(i)=length(ci);   xi=x(:,ci);   m(:,i)=mean(xi,2);   v(:,i)=std(xi,1,2).^2;end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -