function poisson_next_event_test ( )

%*****************************************************************************80
%
%% poisson_next_event_test() tests poisson_next_event().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 January 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'POISSON_NEXT_EVENT_TEST:\n' );
  fprintf ( 1, '  POISSON_NEXT_EVENT simulates a Poisson process\n' );
  fprintf ( 1, '  until a single event has occurred.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Simulate a Poisson process, for which, on average,\n' );
  fprintf ( 1, '  LAMBDA events occur per unit time.\n' );
 
  lambda = 0.5;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  LAMBDA = %g\n', lambda );

  t_total = 0.0;
  event = 0;
  while ( t_total < 10.0 )
    t = poisson_next_event ( lambda );
    event = event + 1;
    t_total = t_total + t;
    fprintf ( 1, '  Event #%d occurs at time %g, after waiting %g\n', event, t_total, t )
  end

  return
end
