预览加载中,请您耐心等待几秒...
1/5
2/5
3/5
4/5
5/5

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

模式识别的一些matlab程序 最小错误率Bayes分类器的设计与检验 clc clear X1=10000; MU1=2.0; SIGMA1=0.2; Y1=normrnd(MU1,SIGMA1,X1,1); X2=5000; MU2=1.0; SIGMA2=0.2; Y2=normrnd(MU2,SIGMA2,X2,1); Y=[Y1;Y2]; Pw1=X1/(X1+X2); Pw2=X2/(X1+X2); T1=find(normpdf(Y1,MU1,SIGMA1)*Pw1>normpdf(Y1,MU2,SIGMA2)*Pw2); T2=find(normpdf(Y2,MU2,SIGMA2)*Pw2>normpdf(Y2,MU1,SIGMA1)*Pw1); et=(X1-length(T1)+X2-length(T2))/(X1+X2); t=fsolve('fun1',1); e=quadl('fun2',-10000,t)+quadl('fun3',t,10000); %fun1 functione=fun1(x) MU1=2.0; SIGMA1=0.2; MU2=1.0; SIGMA2=0.2; e=normpdf(x,MU1,SIGMA1)*2/3-normpdf(x,MU2,SIGMA2)*1/3; %fun2 functiony=fun2(x) MU1=2.0; SIGMA1=0.2; MU2=1.0; SIGMA2=0.2; y=normpdf(x,MU1,SIGMA1)*2/3; %fun3 functiony=fun3(x) MU1=2.0; SIGMA1=0.2; MU2=1.0; SIGMA2=0.2; y=normpdf(x,MU2,SIGMA2)*1/3; 窗函数法高斯分布 clc clear load('TestData.mat') Y=[Y1;Y2]; %hist([Y1;Y2],x) hn=0.01; x=0:0.01:3; %y=1/15000*sum(1/hn*normpdf((x-Y),MU,SIGMA)); fori=1:3/0.01+1 y(i)=1/15000*sum(1/hn*normpdf((x(i)-Y)/hn,0,1)); end plot(x,y) holdon MU1=2.0; SIGMA1=0.2; MU2=1.0; SIGMA2=0.2; z=normpdf(x,MU1,SIGMA1)*2/3+normpdf(x,MU2,SIGMA2)*1/3; plot(x,z,'r') 近邻法高斯分布 clc clear load('TestData.mat') Y=[Y1;Y2]; Y=sort(Y); x=0:0.01:3; kn=100; fori=1:3/0.01+1 j=1; while1 ifabs(Y(j)+Y(j+kn-1)-2*x(i))<abs(Y(j+1)+Y(j+kn)-2*x(i)) break; else j=j+1; end ifj==15000-kn+1 break; end end y(i)=kn/15000/(Y(j+kn-1)-Y(j)); end plot(x,y) holdon MU1=2.0; SIGMA1=0.2; MU2=1.0; SIGMA2=0.2; z=normpdf(x,MU1,SIGMA1)*2/3+normpdf(x,MU2,SIGMA2)*1/3; plot(x,z,'r') Fisher线性变换 clc clear X1=5; One1=ones(X1,1); SIGMA1=0.2; Y1=normrnd([One1.*2One1.*3],SIGMA1,X1,2); X2=5; One2=ones(X2,1); MU2=3.0; SIGMA2=0.2; Y2=normrnd([One2.*3,One2.*2],SIGMA2,X2,2); plot(Y1(:,1),Y1(:,2),'r*',Y2(:,1),Y2(:,2),'bo') m1=mean(Y1); m2=mean(Y2); S1=(Y1-One1*m1)'*(Y1-One1*m1); S2=(Y2-One2*m2)'*(Y2-One2*m2); sw=S1+S2; w=inv(sw)*(m1-m2)'; Y=[Y1;Y2]; z=Y*w; holdon t=z*w'/norm(w)^2; plot(t(:,1),t(:,2)) fori=1:X1+X2 plot([Y(i,1)t(i,1)],[Y(i,2)t(i,2)],'-.') end axis([-13.5-13.5]) grid 一种基于最近邻优先的知识聚类算法 clearall clc I