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

📄 vqinitcenter.m

📁 一个关于数据聚类和模式识别的程序,在生物化学,化学中因该都可以用到.希望对大家有用,谢谢支持
💻 M
字号:
function center = vqInitCenter(data, clusterNum, method)
% vqInitCenter: Find initial centers for VQ or k-means
%	Usage: center = vqInitCenter(data, clusterNum, method)

%	Roger Jang, 20041204

if nargin<3; method=1; end
switch method
	case 1
		% ====== Method 1: Randomly pick clusterNum data points as cluster centers
		dataNum = size(data, 2);
		temp = randperm(dataNum);
		center = data(:, temp(1:clusterNum));
	case 2
		% ====== Method 2: Choose clusterNum data points closest to mean vector
		meanVec = mean(data, 2);
		distMat = pairwiseSqrDistance(meanVec, data);
		[minDist, colIndex] = sort(distMat);
		center = data(:, colIndex(1:clusterNum));
	case 3
		% ====== Method 3: Choose clusterNum data points furthest to the mean vector
		meanVec = mean(data, 2);
		distMat = pairwiseSqrDistance(meanVec, data);
		[minDist, colIndex] = sort(-distMat);
		center = data(:, colIndex(1:clusterNum));
	case 4
		% ====== Method 4: Choose first few data as the centers
		center = data(:, 1:clusterNum);
	otherwise
		error('Unknown method!');
end

⌨️ 快捷键说明

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