function [F,ll] = norm_cdf(x,params)
% [F,ll] = norm_cdf(x, [ muX , sigmaX  ])
% return CDF of normal distribution
%    x     - set of values at which the CDF is computed
%    [muX, sigmaX] - a vector containing the mean and standard deviation 
%
%    Reference: http://en.wikipedia.org/wiki/normal_distribution

  if nargin == 1
   muX    = 0;
   sigmaX = 1;
  else 
    muX    = params(1);		% mean of X
    sigmaX = params(2);		% standard deviation of X
  end

  F = ( 1 + erf( (x - muX)/sigmaX/sqrt(2) ) )/2;

% the log likelihood of the sample x from the a normal distribution with 
% the given median and coefficient of variation 
  if nargout == 2,  
    ll = sum(log(norm_pdf(x,muX,sigmaX))) 
  end

% -------------------------------------------------------------------- norm_cdf 
% HP Gavin 2024-02-20
