function y = kscdf(x, epsi)
%-----------------------------------
% Distribution of Kolmogorov-Smirnov
% Statistic K(x) = P(sqrt(n)*Dn <= x)
%-----------------------------------
if nargin < 2
    epsi=10^(-10);
end  
if x <= epsi
        y = 0;
else
    k  =  1;
    y  =  1;
    aadd = 1;
    while aadd > epsi
    add = (-1).^k .* exp(- 2.*k.^2.*x.^2);
    y = y + 2. * add;
    k = k+1;
    aadd = abs(add);
    end
end
    %--------------------------------------------------------    
        