function x = log_series_sample ( a )

%*****************************************************************************80
%
%% log_series_sample() samples the Logarithmic Series PDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 March 1999
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Luc Devroye,
%    Non-Uniform Random Variate Generation,
%    Springer-Verlag, New York, 1986, page 547.
%
%  Input:
%
%    real A, the parameter of the PDF.
%    0.0 < A < 1.0.
%
%  Output:
%
%    integer X, a sample of the PDF.
%
  u = rand ( 1, 1 );
  v = rand ( 1, 1 );

  x = floor ( 1.0 + log ( v ) / ( log ( 1.0 - ( 1.0 - a )^u ) ) );

  return
end
