function F = normdist(x)
% F = normdist(x) calculates the probability that X<=x, where X is N(0,1) 
%                   random variable.
%      
%  F(x) = 1/sqrt(2*pi) * integral of e^(-(t^2)/2) from -inf to x.
%

% Written by Ulf Brannlund, April 23, 1993
if ~isreal(x) ; error ('Input x needs to be real'); end
if x > 0
  F = 0.5+erf(x/sqrt(2))/2;
else 
  F = erfc(-x/sqrt(2))/2;
end
    