Fisher线性判别与感知器算法Matlab实现

参考用书:

Fisher线性判别与感知器算法Matlab实现_第1张图片

本文是在学习此书Chapter4时,跑的实验。

4.1.4 Fisher‘s Linear Discriminate


function [w y1 y2 Jw] = FisherLinearDiscriminat(data, label)
% FLD Fisher Linear Discriminant.
% data : D*N data
% label : {+1,-1}
% Reference:M.Bishop Pattern Recognition and Machine Learning p186-p189

% compute means and scatter matrix
%-------------------------------
inx1 = find( label == 1);
inx2 = find( label == -1);
n1 = length(inx1);
n2 = length(inx2);

m1 = mean(data(:,inx1),2);
m2 = mean(data(:,inx2),2);

S1 = (data(:,inx1)-m1*ones(1,n1))*(data(:,inx1)-m1*ones(1,n1))';
S2 = (data(:,inx2)-m2*ones(1,n2))*(data(:,inx2)-

你可能感兴趣的:(机器学习)