模式识别matlab程序.doc_第1页
模式识别matlab程序.doc_第2页
模式识别matlab程序.doc_第3页
模式识别matlab程序.doc_第4页
模式识别matlab程序.doc_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

模式识别的一些matlab程序最小错误率Bayes分类器的设计与检验clcclearX1 = 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);%fun1function e = 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;%fun2function y = fun2(x)MU1 = 2.0;SIGMA1 = 0.2;MU2 = 1.0;SIGMA2 = 0.2;y = normpdf(x,MU1,SIGMA1)*2/3;%fun3function y = fun3(x)MU1 = 2.0;SIGMA1 = 0.2;MU2 = 1.0;SIGMA2 = 0.2;y = normpdf(x,MU2,SIGMA2)*1/3;窗函数法高斯分布clcclearload(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);for i = 1:3/0.01+1 y(i) = 1/15000*sum(1/hn*normpdf(x(i)-Y)/hn, 0, 1);endplot(x,y)hold onMU1 = 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)近邻法高斯分布clcclearload(TestData.mat)Y = Y1;Y2;Y = sort(Y);x = 0:0.01:3;kn = 100;for i = 1:3/0.01+1 j = 1; while 1 if abs(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 if j = 15000-kn+1 break; end end y(i) = kn/15000/(Y(j+kn-1)-Y(j);endplot(x, y)hold onMU1 = 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线性变换clcclearX1 = 5;One1 = ones(X1, 1);SIGMA1 = 0.2;Y1 = normrnd(One1.*2 One1.*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;hold ont = z*w/norm(w)2;plot(t(:,1), t(:,2)for i = 1:X1+X2 plot(Y(i,1) t(i,1), Y(i,2) t(i,2), -.)endaxis(-1 3.5 -1 3.5)grid一种基于最近邻优先的知识聚类算法clear allclcI = imread(InPut.bmp);M = rgb2gray(I);clear II = im2bw(M,254/255);clear MIgl = I;%进行第一次聚类Igl = process(Igl, 7);subplot(1,2,1)subimage(I)subplot(1,2,2)subimage(Igl)%第一次%第.次% processfunction Igl = process(I, r)A B = find(I = 0);A = round(mean(A);B = round(mean(B);X, Y = FindNextPoint(I, A, B, 0)Gx, Gy, Igl = FindGroupPoint(I, X, Y, r, 0);% FindNextPointfunction X, Y = FindNextPoint(I, A, B, x);a, b = size(I);temp = max(A, B, a - A, b - B);for i = 1 : temp Q = I(A-i:A+i,B-i:B+i); X, Y = find(Q = x); if length(X) = 0 X = X(1) + A-i - 1; Y = Y(1) + B-i - 1; break; endend% FindGroupPointfunction Gx, Gy, Igl = FindGroupPoint(I, X, Y, r, x)Igl = I;whil

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论