function cdf = discrete_my_cdf ( x, a, b )

%*****************************************************************************80
%
%% discrete_my_cdf() evaluates the Discrete CDF.
%
%  Discussion:
%
%    Had to insert the idiotic "_my" in the name because Octave has a
%    similarly named function in its automatically installed package.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 September 2004
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer X, the item whose probability is desired.
%
%    integer A, the number of probabilities assigned.
%
%    real B(A), the relative probabilities of outcomes
%    1 through A.  Each entry must be nonnegative.
%
%  Output:
%
%    real CDF, the value of the CDF.
%
  if ( x < 1 )
    cdf = 0.0;
  elseif ( x < a )
    cdf = sum ( b(1:x) ) / sum ( b(1:a) );
  elseif ( a <= x )
    cdf = 1.0;
  end

  return
end
