function s = ginimd(data)
%Normalized Gini Mean Difference 
%Better Algorithm
%x =randn(1, 2000);
%s = ginimd(x)
%

data = data(:);
n = length(data);
if(n > 6100)
    error('Too large sample size, I form a matrix n x n!')
end
% 
a = repmat(data', n,1);
adm = abs(a - a');
clear a
udm = triu(adm);
clear adm
gini = sum(udm(:))/nchoosek(n,2);
s = gini * sqrt(pi)/2
