% n_poisson( rate) - generate Poisson random variable
%
function n = n_poisson( rate)

nexp_rate = exp(-rate);

n = 0;
p = rand(1,1);

while( p >= nexp_rate)	% based on exponential interarrival times
  n = n + 1;
  p = p * rand(1,1);
end
