function [ x, seed ] = log_normal_truncated_ab_sample ( mu, sigma, a, b, seed )

%*****************************************************************************80
%
%% LOG_NORMAL_TRUNCATED_AB_SAMPLE samples the Log Normal truncated AB CDF.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    22 March 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real MU, SIGMA, the parameters of the log normal PDF.
%    0.0 < SIGMA.
%
%    Input, real A, B, the lower and upper truncation limits.
%    A < B.
%
%    Input/output, integer SEED, a seed for the random number generator.
%
%    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, '  Parameters are not legal.\n' );
  end

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

  [ cdf, seed ] = r8_uniform_ab ( lncdf_a, lncdf_b, seed );

  x = log_normal_cdf_inv ( cdf, mu, sigma );

  return
end

