首页 > 其他 > 详细

LDA

时间:2017-05-13 16:25:04      阅读:285      评论:0      收藏:0      [点我收藏+]

clc;close all;clear all
c1=[2 2 2;
1 2 3];
c2=[4 5 6;
3 3 4];
c=[c1 c2];
plot(c1(1,:),c1(2,:),‘*‘,c2(1,:),c2(2,:),‘*‘);axis([0 8 0 8]);hold on
u=mean(c,2);
u1=mean(c1,2);
u2=mean(c2,2);

s1=zeros(2,2);
s2=zeros(2,2);
for i=1:3
s1=s1+(c1(:,i)-u1)*(c1(:,i)-u1)‘;
s2=s2+(c2(:,i)-u2)*(c2(:,i)-u2)‘;
end
SB=s1+s2;
w=inv(SB)*(u1-u2);
w=w/sqrt(sum(w‘*w));

v=[w(2);-w(1)];
b=-v‘*u;
x1=0:10;
x2=(-b-v(1)*x1)/v(2);
plot(x1,x2);hold on
c=c-[u u u u u u];
p=w‘*c;
x=w*p;
x=x+[u u u u u u]
plot(x(1,:),x(2,:),‘o‘)

LDA

原文:http://www.cnblogs.com/xlqtlhx/p/6849263.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!