function random_walk_1d_histogram ( step_num, walker_num )

%*****************************************************************************80
%
%% RANDOM_WALK_1D_HISTOGRAM makes a histogram of multiple random walkers.
%
%  Discussion:
%
%    The program takes a given number of walkers who start at 0, allows each
%    walker to take one random step and then displays a  histogram of the results,
%    that is, it shows where each walker is.  
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    08 November 2009
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer STEP_NUM, the number of steps to take.
%
%    Input, integer WALKER_NUM, the number of walkers.
%
  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'RANDOM_WALK_1D_HISTOGRAM:\n' );
  fprintf ( 1, '  MATLAB version\n' );
%
%  Clear the plotting frame.
%
  clf
%
%  X stores the location of each walker.
%
  x = zeros(walker_num,1);

  for step = 0 : step_num
%
%  Ask HIST for one bin for each X value from MIN(X) to MAX(X).
%
    min_x = min ( x );
    max_x = max ( x );
    bin_num = min ( max_x - min_x + 1, 101 );
%
%  Make the histogram and annotate it.
%
    hist ( x, bin_num );
 
    title_string = sprintf ( '1D Random Walkers - %d walkers, %d steps', walker_num, step );
    title ( title_string );
    xlabel ( 'X' )
    ylabel ( 'Number of walkers' );

    pause ( 5 )

    x(1:walker_num) = x(1:walker_num) + 2 * floor ( 2 * rand (walker_num,1) ) - 1;

  end

  hold off
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'RANDOM_WALK_1D_HISTOGRAM:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  return
end
