function n = poisson_fixed_time ( lambda, time )

%*****************************************************************************80
%
%% poisson_fixed_time() counts the Poisson events in a fixed time.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 September 2012
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real LAMBDA, the average number of events per unit time.
%
%    real TIME, the amount of time to observe.
%
%  Output:
%
%    integer N, the number of Poisson events observed.
%
% rng ( 'shuffle' );

  n = 0;
  t = 0.0;

  while ( t < time )
    dt = - log ( rand ( 1, 1 ) ) / lambda;
    n = n + 1;
    t = t + dt;
  end

  return
end
