function y = ks2cdf(x, epsi)
%-----------------------------------
% Distribution of the Supremum/Infimum of
% Brownian Bridge Process on [0,1]
% sup Brownian Bridge Distribution
%  P(sup_{t \in (0,1)} |BB(t)|\leq x)
%-----------------------------------
if nargin < 2
    epsi=10^(-10);
end  
if x <= epsi
        y = 0;
else
    y = 0;
    k = 1;
    add = 2 * epsi;
    while add > epsi
    add = exp(- 2.*k.^2.*x.^2);
    y = y + 2. * add;
    k = k + 1;
    end
    y = 1 - y;
end
    %--------------------------------------------------------    
        