function cdf = log_normal_truncated_ab_cdf ( x, mu, sigma, a, b )

%*****************************************************************************80
%
%% log_normal_truncated_ab_cdf() evaluates the Log Normal truncated AB CDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 March 2016
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X, the argument of the PDF.
%    0.0 < X.
%
%    real MU, SIGMA, the parameters of the log normal PDF.
%    0.0 < SIGMA.
%
%    real A, B, the lower and upper truncation limits.
%    A < B.
%
%  Output:
%
%    real CDF, the value of the CDF.
%
  check = log_normal_truncated_ab_check ( mu, sigma, a, b );

  if ( ~ check )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'LOG_NORMAL_TRUNCATED_AB_CDF - Fatal error!\n' );
    fprintf ( 1, '  Illegal parameter values.\n' );
    error ( 'LOG_NORMAL_TRUNCATED_AB_CDF - Fatal error!' );
  end

  if ( x <= a )

    cdf = 0.0;

  elseif ( b <= x )

    cdf = 1.0;

  else

    lncdf_a = log_normal_cdf ( a, mu, sigma );
    lncdf_b = log_normal_cdf ( b, mu, sigma );
    lncdf_x = log_normal_cdf ( x, mu, sigma );

    cdf = ( lncdf_x - lncdf_a ) / ( lncdf_b - lncdf_a );

  end

  return
end

