Q4) How can we model the time required for the next events in a Poisson process?

Gamma Continuous

Basically the exponential distribution, except it can tell you how long you need to wait until the th occurrence of an event, instead of only the first.

  • is the gamma function evaluated at , which is an extension of the factorial function to real and complex numbers. For positive integers, .
  • Note: Like the exponential distribution, you can either input the ‘rate’ of the event or the ‘mean’ (waiting time). Again, they are just inverses of each other.
  • The above pdf assumes you are using = mean (i.e a plane flies past every 20 minutes 3 planes per minute)

The gamma distribution models the time required for a specified number of events to occur in a Poisson process. Its parameters are:

  • Shape parameter
  • Scale parameter (mean waiting time)
  • Expected value (mean) =
  • Variance =

If you get the math, good work. If you don’t - this book isn’t the place to learn it.

All you need to take away is that this gamma distribution function is able to tell you the exact probability that it will be another 22 minutes, 33 seconds and 23832… milliseconds until you see the 5th plane fly past.

Logically, since the exponential is the wait time till one event, the sum of n iid exponentials has a Gamma distribution.



Q4.2) Poisson in disguise

Question Your service provides an API endpoint for users. On average, it receives 3 calls per minute. Calculate the probability that you have to wait more than 5 minutes for the 12th API call.

Using Gamma

Using Poisson

The event that you have to wait more than 5 minutes for the 12th call, is the same as the event that there are less than 12 calls in the 5 minute window - logically, they are saying the same thing*.

Currently, the number of api calls in a 1 minute window is

So, the number of api calls in a 5 minute window is

p1 <- 1-pgamma(5, shape=12, rate=3) p2 <- ppois(11, 15)

** *Think about it: ** If there are only 10 api calls in the first 5 minutes, then clearly we will have to ‘wait more than 5 minutes’ to see the 12th! If a total of 13 calls happen in the first 5 minutes, then the 12th call already happened in the first 5 minutes.