



n=100;
F0 = @(x )   normcdf(x)
sample = sort(  randn(n,1)+0.1*exprnd(2, n,1)  );
nomega2 = 1/(12*n);
for i = 1:n
    nomega2 = nomega2 + (F0(sample(i) ) - (2*i -1)/(2*n) )^2;
end
   nomega2
   
   pval = 1 - nomega2cdf(nomega2)
   
   
   xi =  [ -2.91    -1.74    -1.20   -1.14    -1.08    -0.83  ...
  -0.78    -0.75    -0.30    0.29    0.32     0.48  ...
    0.67     0.71     0.72     0.88     1.03     1.37  ...
    1.43     1.63 ];

ni =    [ 4     3     7     7     1     4     4     6     7     7 ...
           2     6     6     1     1     4     9     3     5     2];

n=sum(ni)
pi = ni./n
cpi = cumsum(pi)
nome = 0;
for i = 1:20
  nome = nome + ni(i) * (pi(i)^2/12 + (F0(xi(i)) - cpi(i)  + pi(i)/2)^2);
end
nome
 pval = 1 - nomega2cdf(nome)
 
 %simple sample
 
 aa=[];
 for i = 1:20
aa = [aa   xi(i)*ones(1,ni(i))];
end

 nomega2 = 1/(12*n);
for i = 1:n
    nomega2 = nomega2 + (F0(aa(i) ) - (2*i -1)/(2*n) )^2;
end
   nomega2
   
   pval = 1 - nomega2cdf(nomega2)

 
   
   
   
   