Code covered by the BSD License  

Highlights from
Discriminant Analysis Programme

image thumbnail
from Discriminant Analysis Programme by Bartolomeu Rabacal
Discrimination and Classification of data to and from groups with classical/robust estimation

Q=galg(TList, numGrp)
function Q=galg(TList, numGrp)

% G algorithm

% Flury, Bernhard. Commom Principal Components and Related multivariate
% Models

M=0;
tol=0.0001;
ifault=0; 
Q=eye(2);

while (ifault==0)
    M=M+1;
 	QOLD=Q;
    Delta=computeDeltaMatrix(TList, numGrp, Q);
    T=computeTMatrix(TList, numGrp, Delta);

    if (abs(T(1,2))<10.^(-10))
        QOPT=eye(2);
        return;
    else
        ratio=(T(2,2)-T(1,1))/T(1,2);
		discr= sqrt(ratio*ratio+4);
		r1=(ratio+discr)/2;
		r2=(ratio-discr)/2;
		r=r1;
		  if (abs(r1)>abs(r2))
              r=r2;
		  end;
		c=1/(sqrt(1+r*r));
		s=r*c;
		Q=[c -s; s c];
		difg=abs(Q(1,2)-QOLD(1,2));
		if  difg<tol
            QOPT=Q ;
		    return;
	    else
            QOLD=Q;
	    end;
	end;
end;

Contact us at files@mathworks.com