
function shat = crouxrouss2(data)
%Croux and Rousseeuw (1992) 
%A smarter algorithm, but breaks if n > 6100
% on Pentium 2Gig
data = data(:);
n = length(data);
if(n > 6100)
    error('Too large sample size, I form a matrix n x n!')
end
% 
coradd = 1.4 + (floor(n/2) == n/2) * 2.4;  
corfactor = n/(n + coradd);
%
a = repmat(data', n,1);
adm = abs(a - a');
clear a
udm = triu(adm);
clear adm
sad = sort(udm(:));
index = n*(n-1)/2 + n + (floor(n/2)+1)*floor(n/2)/2;
shat = 2.2219 * corfactor * sad(index);