function a = runs_simulate ( m, n )

%*****************************************************************************80
%
%% runs_simulate() simulates a case governed by the Runs PDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    27 January 2007
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, N, the parameters of the PDF.
%
%  Output:
%
%    integer A(M+N), a sequence of M 0's and N 1's chosen
%    uniformly at random.
%
  a(1:m) = 0;
  a(m+1:m+n) = 1;

  for i = 1 : m + n - 1

    j = randi ( [ i, m + n ], 1 );

    k    = a(i);
    a(i) = a(j);
    a(j) = k;

  end

  return
end
