5

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.

Nick Cox
  • 56,404
  • 8
  • 127
  • 185

3 Answers3

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
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.

Nick Cox
  • 56,404
  • 8
  • 127
  • 185
Linda H
  • 66
  • 1
  • 3
    Wouldn'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
  • 1
    Thank 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