function x = log_normal_truncated_ab_sample ( mu, sigma, a, b )

%*****************************************************************************80
%
%% log_normal_truncated_ab_sample() samples the Log Normal truncated AB CDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    02 February 2021
%
%  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 X, a random sample
%
  check = log_normal_truncated_ab_check ( mu, sigma, a, b );

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

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

  cdf = lncdf_a + ( lncdf_b - lncdf_a ) * rand ( 1, 1 );

  x = log_normal_cdf_inv ( cdf, mu, sigma );

  return
end

