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

📄 pnmix.m

📁 该工具箱是用于统计模式识别的
💻 M
字号:
function [hellipse,hcenter]=pnmix(X,MI,SIGMA,I,hellipse,hcenter)%  [hellipse,hcenter]=pnmix(X,MI,SIGMA,I,hellipse,hcenter)%% PNMIX vizualizes mixture of normal distributions in 2D space. %  Each normal distribution is determined by a pair of mean values and %  covariance matrix. The mean value is vizualized as a point and the %  covariance matrix as en ellipse. A size of the ellipse is determined %  in order to contain all the points belonging to given class which %  the ellipse describes.%%  Input and output arguments hellipse and hcenter contain%  handles of graphics objects (ellipses and their centers) and%  if they enter the function, the old graphics objects vanish and %  then new objects are plotted.%%  The function is useful for vizualization of results of the unsupervised%  learning algorithms (see help of UNSUNI, UNSUND).%% Input:%   X [NxK] contains K points which are N-dimensional, X=[x_1,x_2,...,x_K].%   I [1xK] contains class labels for all the points.%   MI [NxM] mean values for each class, MI=[mi_1,mi_2,...,mi_M]%   SIGMA [Nx(MxN)] covariance matrices for each class,%      SIGMA=[sigma_1,sigma_2,...,sigma_M].%   hellipse [vector], hcenter [vector] handlers of graphics objects.%% Output:%   hellipse [vector], hcenter [vector] handlers of graphics objects.%% See also UNSUNI, UNSUND, UNSUDEMO.%% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz% Written Vojtech Franc (diploma thesis) 10.11.1999, 23.12.1999% Modifications:% 22. 6.00 V. Hlavac, comments polished.if nargin < 5,  hellipse=-1;endDIM=size(X,1);N=size(X,2);K=size(MI,2);maxr=zeros(1,K);for i=1:N,   r=sqrt(mahalan(X(:,i),MI(:,I(i)),SIGMA(:,(I(i)-1)*DIM+1:DIM*I(i))));   if maxr(I(i)) < r,      maxr(I(i)) = r;   endendif hellipse==-1,   for i=1:K,%%%      [x,y]=ellipse(inv(SIGMA(:,(i-1)*DIM+1:DIM*i)),30,maxr(i),MI(:,i));      [x,y]=ellips(MI(:,i),SIGMA(:,(i-1)*DIM+1:DIM*i),maxr(i),30);      hellipse(i)=plot(x,y,'k','EraseMode','xor');      hcenter(i)=plot(MI(1,i),MI(2,i),'+k','EraseMode','xor');      drawnow;   endelse   for i=1:K,%%%      [x,y]=ellipse(inv(SIGMA(:,(i-1)*DIM+1:DIM*i)),30,maxr(i),MI(:,i));      [x,y]=ellips(MI(:,i),SIGMA(:,(i-1)*DIM+1:DIM*i),maxr(i),30);      set(hellipse(i),'XData',x,'YData',y,'Visible','on');      set(hcenter(i),'XData',MI(1,i),'YData',MI(2,i),'Visible','on');      drawnow;   endend

⌨️ 快捷键说明

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