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

sestck(x,start,c,k,tol)
function scale = sestck(x,start,c,k,tol)

% Computes Tukey's biweight objectief function (scale) corresponding 
% with the mahalanobis distances x.  

if start>0 
    s = start;
else y=abs(x);
    [n,p]=size(x);
    if  ((n==1) & (p>1))
        x = x'; [n,p] = size(x);
    end
    x = sort(x);
    if  floor(n/2) == n/2
        s = (x(n/2,:) + x((n+2)/2,:))/2;
    else
        s = x((n+1)/2,:);
    end
    s = s/0.6745;
end
crit = 2*tol;
rhoold = mean(rhobiweight(x/s,c))-k;
while crit >= tol
    delta = rhoold/mean(psibiweight(x/s,c).*(x/(s^2)));
    isqu = 1; okay = 0;
    while ((isqu<10) & (okay~=1))
        rhonew = mean(rhobiweight(x/(s+delta),c))-k;
        if abs(rhonew) < abs(rhoold)
            s = s+delta;
            okay = 1;
        else
            delta = delta/2;
            isqu = isqu+1;
        end     
    end
    if isqu == 10
        crit = 0;
    else
        crit = (abs(rhoold)-abs(rhonew))/(max([abs(rhonew),tol]));
    end
    rhoold = rhonew;
end
scale = abs(s);

Contact us at files@mathworks.com