How can I generate events using the Poisson distribution in R? The events could be the occurrence of floods in the next 1000 years at a given rate of occurrence per year.
Asked
Active
Viewed 6,357 times
5
3 Answers
3
The following gives you one inter-event time
- log(runif(1)) / lambda
where lambda is the intensity of your Poisson process so the time-series of times of n events is obtained as:
cumsum(-log(runif(n))/lambda)
mts
- 81
-
1
-
-
I'm not sure why you think so.
rexp(n,lambda)generates n random exponential deviates with rate parameter lambda, the same as-log(runif(n))/lambda– Ben Bolker Jan 06 '19 at 16:30
2
How about
rate <- 0.123456
period <- 1000
start <- 2013.5
floods <- runif(rpois(1,period*rate), min=start, max=start+period)
since the dates are uniformly distributed within the time interval
Henry
- 39,459
0
You should use the command rpois(n, 1000*lambda), where lambda is the average number of occurrences per year (and hence the occurrence in 1000 years should be 1000 times more), and n is the number of random values to return.
-
3Wouldn't these be counts of floods during 1000 years, and not the events (or at least their times) themselves? What you need to make progress with this question is the relationship between the Poisson distribution for counts and the Exponential waiting time between them. – whuber May 23 '13 at 15:08
-
1Thank you for the response Linda H,@ whuber I think its the count of events, I would need to have the times the events would occur instead.Thank you for the insights – Bhekimpilo Ndlovu May 27 '13 at 12:40
Rcode. Then we will really know we're in the Matrix. :-) – whuber May 23 '13 at 13:16