function shat = crouxrouss(data)

%Croux and Rousseeuw (1992) 
%A Naive Algorithm, breaks in n > 500



data = data(:);
n = length(data);
if(n > 500)
    error('Too large sample size, I have to do a double loop!')
end
absdiff =[];
for( i = 1:(n-1))
    for(j = (i+1):n)
        absdiff = [absdiff abs(data(i) - data(j))];
    end
end
sad = sort(absdiff);
index = (floor(n/2)+1)*floor(n/2)/2;
coradd = 1.4 + (floor(n/2) == n/2) * 2.4;  
corfactor = n/(n + coradd);
shat = 2.2219 * corfactor *  sad(index);

