lambdawilks.m

来自「用于matlab环境下的支持向量机svm的工具箱」· M 代码 · 共 34 行

M
34
字号
function  LW=lambdawilks(x,y)

% Usage
%  LW=lambdawilks(x,y)
%
%  Calculate the Lambda-Wilks value of data x associated with 
%  label y
%  
%  This algo can handle arbitrary number of class but y must
%  coded   in the following way
%  
%   y=i  means x is in class i

if ~isempty(x)
    nbclass=max(y);
    nbdata=size(x,1);
    nbfeat=size(x,2);
    W=zeros(nbfeat,nbfeat);
    %keyboard
    for i=1:nbclass
        ind=find(y==i);
        nbclass_i=length(ind);
        W=W+nbclass_i*cov(x(ind,:),1);
    end;
    W=W/nbdata;
    T=cov(x,1);
    LW=det(W)/det(T);
else
    LW=NaN;
end;



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?