function cdf = negative_binomial_cdf ( x, a, b )

%*****************************************************************************80
%
%% negative_binomial_cdf() evaluates the Negative Binomial CDF.
%
%  Discussion:
%
%    A simple summing approach is used.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 January 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer X, the argument of the CDF.
%
%    integer A, a parameter of the PDF.
%    0 <= A.
%
%    real B, a parameter of the PDF.
%    0 < B <= 1.
%
%  Output:
%
%    real CDF, the value of the CDF.
%
  cdf = 0.0;

  for y = a : x

    cnk = nchoosek ( y - 1, a - 1 );

    pdf = cnk * b ^ a * ( 1.0 - b ) ^ ( y - a );

    cdf = cdf + pdf;

  end

  return
end
