function x = bernoulli_sample ( a )

%*****************************************************************************80
%
%% bernoulli_sample() samples the Bernoulli PDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 April 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real A, the probability of success on one trial.
%    0.0 <= A <= 1.0.
%
%  Output:
%
%    integer X, a sample of the PDF.
%
  cdf = rand ( 1, 1 );

  x = bernoulli_cdf_inv ( cdf, a );

  return
end
