function x = empirical_discrete_sample ( a, b, c )

%*****************************************************************************80
%
%% empirical_discrete_sample() samples the Empirical Discrete PDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 September 2004
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer A, the number of values.
%    0 < A.
%
%    real B(A), the weights of each value.
%    0 <= B(1:A) and at least one value is nonzero.
%
%    real C(A), the values.
%    The values must be distinct and in ascending order.
%
%  Output:
%
%    real X, a sample of the PDF.
%
  cdf = rand ( 1, 1 );

  x = empirical_discrete_cdf_inv ( cdf, a, b, c );

  return
end
