亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? agmbclust.m

?? 基于AGGLOMERATIVE模型的聚類算法matlab實現
?? M
字號:
function Z = agmbclust(X);

% AGGLOMERATIVE MODEL BASED CLUSTERING - NO INITIAL PARTITION
%
% This function does the agglomerative model-based clustering
% of Fraley. NOTE that this one does the MB agglomerative 
% clustering from the FULL data set.
%
%   Z = AGMBCLUST(X)
%
%   The output Z contains the cluster array that MATLAB expects.
%   This can be used in the DENDROGRAM or the RECTPLOT plotting 
%   functions.

%   Model-based Clustering Toolbox, January 2003


% NOTE THAT THIS ONE DOES THE IMPLEMENTATION OF CHRIS IN THE
% PAPER GIVEN IN THE CLASS NOTES. THIS EQUATION IS SLIGHTLY 
% DIFFERENT THAN THE ONE IN THE PUBLISHED PAPER. 
% NOTE ALSO THAT THIS MODIFIED TERM IS NEEDED WHEN THE INITIAL
% PARTITION IS SINGLETONS.

% NOTE THAT WE ARE GOING TO USE THE STRUCTURE OF THE CLUSTERING
% THAT COMES FROM MATLAB - SO WE CAN DO THE DENDROGRAM.

[n,p] = size(X);
% Get script W - sample cross-product matrix - all data.
Ws = cov(X)*(n-1);
% Get the trace of it.
trWs = trace(Ws);
% Get the constant term.
cons = trWs/(n*p);

% Matrix to store the resulting cluster structure. This matches MATLAB's.
Z = zeros(n-1,3);   % first two cols are cluster numbers, 3rd is criterion.

G = n;	% initially there are n singleton clusters.

% set up some storage space.
nk = ones(1,G);	% Store the number in each cluster
sk = X;				% Store the sum of the observations in each cluster.
trWk = zeros(1,G);	% Store the trace of each cluster.
detWk = zeros(1,G);	% Store the determinant of each cluster.
Wk = cell(1,G);		% Store the cross-product matrices in each.
tmp = zeros(G);		% This will be used to temporarily store the delta_ij
obf = zeros(1,n); % This will store the value of the objective function.
% Note that the first element corresponds to the initial value. Then each
% successive element is the value of the ojbective function after merging
% two clusters.

% Initial partition is each point in its own cluster.
clabs = 1:n;
ucl = unique(clabs);

% Initial sample-cross product matrices are all zeros.
for i = 1:G
    Wk{i} = zeros(p);
end

% Get the indices for the initial delij.
% These will be the indices for the upper part of the delta_ij matrix.
pp = (n-1):-1:2;
I = zeros(n*(n-1)/2,1);
I(cumsum([1 pp])) = 1;
I = cumsum(I);
J = ones(n*(n-1)/2,1);
J(cumsum(pp)+1) = 2-pp;
J(1)=2;
J = cumsum(J);
% Place to store the delta's for the objective function.
delij = zeros(length(I),1);
% This will store the indices to the pointers to the clusters.
% It is the lowest index of the observations in the cluster.
% Note that I and J are cluster numbers, while ptrij are pointers to
% the cluster index where stuff is stored.
ptrij = [I,J];

% Initialize the delta_ij 
for g = 1:length(I)
	i = I(g);
	j = J(g);
	Wkt = cov(X([i,j],:));
	delij(g) = 2*log(det(Wkt/2) + trace(Wkt/2) + cons) - 2*log(cons);
end

% Initial value of the objective function.
obf(1) = n*log(cons);

% Must do n-1 links
for k = 1:(n-2)
    disp(['Merging clusters ... step ' int2str(k)])

	
% Find the smallest one. Store the value in the Z matrix.
	[iv,im] = min(delij);
    
    % Get the new value of the objective function.
    obf(k+1) = obf(k) + iv;
	
    % These are the two groups that will be merged.
    groupi = I(im);
    groupj = J(im);
	% Put the clusters in the Z matrix.
    Z(k,1:2) = sort([groupi, groupj]);
    Z(k,3) = obf(k+1);

    % Find all of the points belonging to these two groups and reassign labels.
    indi = find(clabs == groupi);
    indj = find(clabs == groupj);	
	clusnum = k+n;
    clabs(indi) = clusnum;		% Recall that clabs is 1-1 with observations.
    clabs(indj) = clusnum;
	% The storage index for the new group is the smallest one.
	indij = min([indi(:);indj(:)]);

	% Update the I and the J values to reflect the new cluster assignment.
	% Recall that I and J correspond to the cluster numbers in the delij and ptrij arrays.
	indi = find(I == groupi | I == groupj);
	indj = find(J == groupi | J == groupj);
	I(indi) = clusnum;
	J(indj) = clusnum;

	% Update the nk, sk, trWk, detWk
	it = ptrij(im,1);	% pointer to the i cluster stuff
	jt = ptrij(im,2);	% pointer to the j cluster stuff
	ni = nk(it); 
	nj = nk(jt);
	nij = sqrt(ni/(nj*(ni+nj)));
	nji = sqrt(nj/(ni*(nj+ni)));
	up =  nji*sk(it,:) - nij*sk(jt,:);
    
    % Now do the actual updates.
    nk(indij) = ni + nj;
	Wk{indij} = Wk{it} + Wk{jt} + up(:)*up(:)';
	detWk(indij) = det(Wk{indij}/nk(indij));
	trWk(indij) = trace(Wk{indij}/nk(indij));
	sk(indij,:) = sk(it,:) + sk(jt,:);

    % Then delete the row in delij and ptrij and I and J.
    % This one is the one that will be combined.
	% Note that I and J will contain the cluster numbers.
	delij(im) = [];
	ptrij(im,:) = [];
    I(im) = [];
    J(im) = [];
	
%	indel = delobs2(I,J);
	
	indel = delobs(I,J,clusnum)';	% subfunction below
    
    % Delete those rows.
    I(indel) = [];
    J(indel) = [];
    delij(indel) = [];
    ptrij(indel,:) = [];
	

    % Find all of the guys that belong to the new cluster.
	indi = find(I==clusnum);
	indj = find(J==clusnum);
	% Update the ptrij to point to where the new cluster info is stored.
	ptrij(indi,1) = indij;
	ptrij(indj,2) = indij;
	
	% Update the delij.
	% First find all of the 'I clusters' that belong to the new cluster
	% and update their delta_ij and ptrij.
	for i = 1:length(indi);
        it = ptrij(indi(i),1);
		jt = ptrij(indi(i),2);	% pointer to the j cluster stuff.
		% First update Wij - this would combine the new cluster plus
        % the j cluster.
        nj = nk(jt);
        ni = nk(it);
        nt = ni + nj;
        st = sk(it,:) + sk(jt,:);
        nij = sqrt(ni/(nj*nt));
        nji = sqrt(nj/(ni*nt));
        up =  nji*sk(it,:) - nij*sk(jt,:);
        Wkt = Wk{it} + Wk{jt} + up(:)*up(:)';
        detWkt = det(Wkt/nt);
        trWkt = trace(Wkt/nt);
		% Then get O(Wij) - O(Wi) - O(Wj)
		delij(indi(i)) = nt*log(detWkt + trWkt + cons) - ...
			ni*log(detWk(it) + trWk(it) + cons) - ...
            nj*log(detWk(jt) + trWk(jt) + cons);
    end
    % Then find all of the 'J clusters' that belong to group i or groupj
    % and update their delta_ij and ptrij.
    for i = 1:length(indj)
        it = ptrij(indj(i),1);
		jt = ptrij(indj(i),2);	% pointer to the j cluster stuff.
		% First update Wij - this would combine the new cluster plus
        % the j cluster.
        ni = nk(it);
        nj = nk(jt);
        nt = ni + nj;
        st = sk(it,:) + sk(jt,:);
        nij = sqrt(ni/(nj*nt));
        nji = sqrt(nj/(ni*nt));
        up =  nji*sk(it,:) - nij*sk(jt,:);
        Wkt = Wk{jt} + Wk{it} + up(:)*up(:)';
        detWkt = det(Wkt/nt);
        trWkt = trace(Wkt/nt);
		% Then get O(Wij) - O(Wi) - O(Wj)
		delij(indj(i)) = nt*log(detWkt + trWkt + cons) - ...
			ni*log(detWk(it) + trWk(it) + cons) - ...
            nj*log(detWk(jt) + trWk(jt) + cons);
    end
    
  
end

% Now do the last one.
% Find the smallest one. Store the value in the Z matrix.
% Get the new value of the objective function.
%[iv,im] = min(delij);
obf(n) = obf(n-1) + delij;
% Put the clusters in the Z matrix.
% These are the last two that can be clustered.
Z(n-1,1:2) = sort([I J]);
Z(n-1,3) = obf(n);


%%%%%%%%%%%%%%%%%%%  FUNCTION - DELOBS %%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
% Check the other way to find deleted observations.
function indel = delobs(I,J,clusnum)

IJ = [I,J];
[n,p] = size(IJ);

inds = find(I==clusnum | J==clusnum);

tmp = IJ(inds,:);	% put into one matrix
ts = sort(tmp,2);	% sort each row

% find the unique rows. These should be the indices we keep.
[b,i,j] = unique(ts,'rows');

% find the ones to delete.
indt = setdiff(1:length(inds) , i);

indel = inds(indt);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品网站在线| 2017欧美狠狠色| 成人动漫精品一区二区| 久久99精品久久久久久国产越南| 亚洲黄色片在线观看| 综合激情成人伊人| 欧美国产精品中文字幕| 日本一区二区视频在线观看| 久久久久国产一区二区三区四区| 久久毛片高清国产| 国产天堂亚洲国产碰碰| 国产欧美精品一区aⅴ影院| 中文字幕va一区二区三区| 一色屋精品亚洲香蕉网站| 亚洲精品国产一区二区精华液 | 久久精品国产精品亚洲综合| 日本成人在线看| 精品无人码麻豆乱码1区2区| 国产一区视频在线看| 国产ts人妖一区二区| 91麻豆国产香蕉久久精品| 欧美亚洲综合色| 日韩欧美一区二区久久婷婷| 久久亚洲综合色| 成人免费一区二区三区视频| 亚洲一区电影777| 六月丁香综合在线视频| 国产91对白在线观看九色| 一本久道久久综合中文字幕| 欧洲一区二区三区在线| 日韩欧美aaaaaa| 国产精品久久久久久久久快鸭| 亚洲激情在线激情| 麻豆91在线观看| 成人av在线观| 7777精品伊人久久久大香线蕉完整版 | 精品久久久久av影院| 国产校园另类小说区| 一区二区三区精品久久久| 久久av资源网| 在线视频综合导航| 久久久久亚洲综合| 亚洲一卡二卡三卡四卡无卡久久| 九九视频精品免费| 欧美在线观看禁18| 中文天堂在线一区| 日韩影院免费视频| 成人激情电影免费在线观看| 在线91免费看| 悠悠色在线精品| 国产精品一区二区你懂的| 欧美色精品在线视频| 欧美国产一区二区| 国产综合久久久久久鬼色| 欧美三级乱人伦电影| 国产精品乱子久久久久| 精品一区二区综合| 在线电影院国产精品| 一区二区三区蜜桃| youjizz久久| 久久精品男人的天堂| 人人狠狠综合久久亚洲| 欧洲av在线精品| 中文字幕亚洲欧美在线不卡| 国产精品影视在线观看| 日韩一区二区影院| 日本伊人午夜精品| 欧美肥大bbwbbw高潮| 亚洲成av人片| 欧美曰成人黄网| 亚洲卡通动漫在线| 97久久超碰国产精品电影| 国产精品色噜噜| 成人黄页在线观看| 中文字幕在线免费不卡| 成人小视频免费在线观看| 久久日一线二线三线suv| 精品在线免费视频| 欧美精品一区男女天堂| 国产乱人伦偷精品视频不卡| 欧美精品一区二区三区蜜臀| 国产一区二区三区香蕉| 久久影视一区二区| 高清在线成人网| 国产精品私人影院| 91香蕉视频在线| 亚洲国产另类精品专区| 欧美高清激情brazzers| 久久国产日韩欧美精品| 久久精品夜色噜噜亚洲a∨| 国产一区二区三区蝌蚪| 国产精品国产三级国产a | 99视频在线精品| 亚洲男帅同性gay1069| 色综合久久综合网| 天使萌一区二区三区免费观看| 欧美精品乱码久久久久久按摩| 蜜桃视频在线一区| 久久久久99精品一区| 91欧美激情一区二区三区成人| 亚洲美女区一区| 日韩一级片网址| 粉嫩av亚洲一区二区图片| 亚洲激情一二三区| 日韩精品一区二区三区swag| 成人深夜在线观看| 五月综合激情网| 国产清纯白嫩初高生在线观看91| 99国产麻豆精品| 日韩av在线发布| 国产精品无码永久免费888| 欧美日韩一区二区三区视频| 久久国产综合精品| 日韩一区欧美一区| 日韩女优电影在线观看| av不卡免费电影| 青青青伊人色综合久久| 中文字幕欧美一| 欧美一区二区不卡视频| 成人高清视频免费观看| 日本免费在线视频不卡一不卡二| 国产精品免费免费| 日韩欧美在线123| 色综合久久久网| 国产精品一区久久久久| 肉丝袜脚交视频一区二区| 国产精品视频你懂的| 日韩欧美高清dvd碟片| 91福利视频网站| 丁香婷婷深情五月亚洲| 蜜桃一区二区三区四区| 午夜婷婷国产麻豆精品| 亚洲视频你懂的| 欧美国产精品v| 精品粉嫩超白一线天av| 欧美久久久影院| 色视频一区二区| 9久草视频在线视频精品| 极品尤物av久久免费看| 日韩二区在线观看| 亚洲尤物在线视频观看| 1区2区3区精品视频| 国产亚洲视频系列| 精品美女一区二区三区| 日韩一级视频免费观看在线| 欧美狂野另类xxxxoooo| 欧美日韩性生活| 欧美日韩在线免费视频| 91久久免费观看| 日本乱人伦aⅴ精品| 91女厕偷拍女厕偷拍高清| 成人av先锋影音| 99久久精品免费观看| av电影在线观看完整版一区二区| 成人av网址在线观看| 99久久综合狠狠综合久久| 91香蕉视频mp4| 欧美亚洲愉拍一区二区| 欧美日韩mp4| 91精选在线观看| 日韩精品专区在线影院观看| 日韩欧美在线综合网| 欧美大片在线观看一区| 久久久久久久av麻豆果冻| 欧美经典一区二区三区| 国产精品传媒入口麻豆| 日韩久久一区二区| 亚洲香肠在线观看| 男女视频一区二区| 国产乱子伦视频一区二区三区| 丁香桃色午夜亚洲一区二区三区 | 亚洲一区二区五区| 亚洲一区二区五区| 美国十次综合导航| 国产精品正在播放| 色综合色狠狠综合色| 欧美二区乱c少妇| xvideos.蜜桃一区二区| 国产精品欧美一区喷水| 亚洲永久免费av| 九九国产精品视频| 成人的网站免费观看| 欧美性生活久久| 久久综合成人精品亚洲另类欧美 | 亚洲女同女同女同女同女同69| 一区二区激情视频| 激情五月婷婷综合网| 成人av网站大全| 欧美嫩在线观看| 国产精品美女久久久久aⅴ| 亚洲精品欧美综合四区| 久久99日本精品| 91丝袜呻吟高潮美腿白嫩在线观看| 欧美性猛片aaaaaaa做受| 欧美v日韩v国产v| 一区二区三区欧美| 国产99久久久国产精品| 91精品中文字幕一区二区三区| 国产精品美女一区二区在线观看| 日韩av电影免费观看高清完整版在线观看|