function cdf = set_discrete_cdf ( n1, n2, pdf )

%*****************************************************************************80
%
%% set_discrete_cdf() sets a CDF from a discrete PDF.
%
%  Discussion:
%
%    Here, we proceed from cell (1,1) to (2,1) to (N1,1), (1,2), (2,2)...(N1,N2).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 July 2009
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N1, N2, the number of rows and columns
%    of PDF data.
%
%    real PDF(N1,N2), the discrete PDF for the cell (I,J),
%    normalized so that the sum over all cells is 1.
%
%  Output:
%
%    real CDF(N1,N2), the discrete CDF for the cell (I,J).
%    CDF(N1,N2) should be 1.
%
  total = 0.0;
  for j = 1 : n2
    for i = 1 : n1
      total = total + pdf(i,j);
      cdf(i,j) = total;
    end
  end

  return
end
