function mean = log_normal_truncated_ab_mean ( mu, sigma, a, b )

%*****************************************************************************80
%
%% log_normal_truncated_ab_mean(): mean of the Log Normal Truncated AB PDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 March 2016
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    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 MEAN, the mean of the PDF.
%
  check = log_normal_truncated_ab_check ( mu, sigma, a, b );

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

  a0 = ( log ( a ) - mu ) / sigma;
  b0 = ( log ( b ) - mu ) / sigma;

  c1 = normal_01_cdf ( sigma - a0 );
  c2 = normal_01_cdf ( sigma - b0 );
  c3 = normal_01_cdf ( + a0 );
  c4 = normal_01_cdf ( + b0 );

  ln_mean = exp ( mu + 0.5 * sigma ^ 2 );

  mean = ln_mean * ( c1 - c2 ) / ( c4 - c3 );

  return
end
