function geyser_bar_prepare ( )

%*****************************************************************************80
%
%% geyser_bar_prepare converts raw geyser data to binned data.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 July 2018
%
%  Author:
%
%    John Burkardt
%
  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'geyser_bar_prepare\n' );
  fprintf ( 1, '  MATLAB/Octave version %s:\n', version ( ) );
  fprintf ( 1, '  Read data about the waiting time between eruptions\n' );
  fprintf ( 1, '  of the Old Faithful geyser.\n' );
  fprintf ( 1, '  Bin this data, for presentation as a bar graph.\n' );
%
%  Load the raw data of durations and waits.
%
  t = load ( 'geyser_data.txt' );
%
%  Keep just the waits.
%
  t = t(:,2);
  t_min = min ( t );
  t_max = max ( t );
%
%  Use 30 bins, which means 30+1 "edges".
%
  bin_num = 30;
  bin_edges = linspace ( t_min - 1.0, t_max + 1.0, bin_num + 1 );
%
%  T_BINNED counts data between successive bin edges.
%
  t_binned = histc ( t, bin_edges );
%
%  Discard the last entry, which counts data greater than the last bin edge.
%
  t_binned = t_binned(1:bin_num);
%
%  Set the average value of each bin.  
%
  bar_center = linspace ( ( bin_edges(1)     + bin_edges(2)    ) / 2, ...
                          ( bin_edges(end-1) + bin_edges(end) ) / 2, ...
                          bin_num );
%
%  Create a single object containing centers and occupancies.
%
  data = [ bar_center', t_binned ];
%
%  Save data to a file.
%
  filename = 'geyser_bar_data.txt';
  save ( filename, '-ascii', 'data' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Binned data saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'geyser_bar_prepare:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  return
end
