I am trying to simulate a poisson process by using the fact that the inter-arrival times are distributed as an exponential distribution.
I want to generate patient arrival times in (say) 1 hour. So, my basic loop in R notation is
while (nextArrival<60)
nextArrival <-prevArrival +rexp(1,0.5)
prevArrival <- nextArrival
where 0.5 is the rate parameter of exponential distribution and I am initializing all the variables correctly.
So, I was expecting that the count of patients arrived in 1 hour would be a Poisson with parameter \lambda*t where t=60. But it turns out that this isn't so, as the mean of my simulated counts is no where close to \lambda*t.
For example, for 5 simulations, the counts were 10 7 8 7 7 which are no where close to 0.5*60. Am I missing something? Thanks in advance!
There does not seem to be anything wrong with your interpretation. I took your code and run it in R:
And obtain counts that look like Poisson variable. You may want to double check your implementation.