资源简介

fisher的matlab实现,可以实现分类和最佳投影平面的显示,并且带有测试代码,可以随机在生成的坐标图上点十个点,程序会自动为点着上相应的颜色,比较直观

资源截图

代码片段和文件信息

%本m文件实现fisher算法,并对两个二维正态分布随机序列
%进行训练,进而可在屏幕上任意取点,程序可直接显示点属
%于第一类还是第二类并着上相应的颜色
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%分别产生x轴和y轴都为正态分布的随机序列
%假设x轴和y轴序列相互独立,可产生二维正态分布随机序列
%w1、w2分别用来保存两个训练集的横坐标和纵坐标
%用normrnd函数产生正态分布函数
% %normrnd(meanomega[rowcolumn])
%mean:均值;omega:标准差
%row:产生随机序列的行数;column:产生随机序列的列数
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 X1 = normrnd(4010[2001]);%产生正态分布函数
 Y1 = normrnd(4010[2001]); 
 w1=[X1 Y1];
 X2 = normrnd(5 10[1001]);
 Y2 = normrnd(0 10[1001]);
 w2=[X2 Y2];
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%以下部分为fisher算法的实现
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%计算样本均值
m1=mean(w1)‘;
m2=mean(w2)‘;
%s1、s2分别代表表示第一类、第二类样本的类内离散度矩阵
s1=zeros(2);
[row1colum1]=size(w1);
for i=1:row1
     s1 = s1 + (w1(i:)‘-m1)*(w1(i:)‘-m1)‘;
end;
s2=zeros(2);
[row2colum

评论

共有 条评论