function generator ( trial_num )

%*****************************************************************************80
%
%% generator() plots a histogram of random values.
%
%  Discussion:
%
%    A histogram of 100,000 random values will show whether they are
%    uniformly distributed or not.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 January 2018
%
%  Author:
%
%    Paul Nahin
%
%  Reference:
%
%    Paul Nahin,
%    Dueling Idiots and Other Probability Puzzlers,
%    Princeton, 2012,
%    ISBN: 978-0691155005.
%
%  Input:
%
%    integer trial_num: the number of trials.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'generator():\n' );
  fprintf ( 1, '  A histogram of %d random values shows whether they are\n', trial_num );
  fprintf ( 1, '  uniformly distributed or not.\n' );
  
  y = rand ( trial_num, 1 );
%
%  Graphics.
%
  clf ( );
  hist ( y, 100 );
  title ( 'Histogram of rand(), a Uniform Random Number Generator' );
  xlabel ( '100 bins, 100,000 numbers' );
  ylabel ( 'bin population' );
  filename = 'generator.png';
  print ( '-dpng', filename );
  fprintf ( '  Graphics saved as "%s"\n', filename );

  return
end

