Simulating Poisson processes using Google Sheets





How can we simulate Poisson processes on a computer or on Google Sheets?

Theory

Consider a Poisson process \(\{N(t)\}\). Given some parameter \(\lambda > 0\), we have the probability distribution given by

\[p_n(t) = \Pr(N(t) = n) = \frac{(\lambda t)^n e^{-\lambda t}}{n!}.\]

We assume that \(N(0) = 0\) almost surely. The value of \(N(t)\) increases by 1 over random periods of time. Let \(T_n\) denote the time at which \(N(t)\) becomes \(n\). Then, \(T_1, T_2, \cdots, T_n, \cdots\) are random variables. Next, let's define \(Q_n = T_n - T_{n-1}\). Of course, we assume \(T_0 = 0\); accordingly, \(Q_1 = T_1\). Since the Poisson process is a Markov process, \(Q_1, Q_2, \cdots, \) are i.i.d. (independent and identically distributed). Let's calculate the cumulative distribution function of \(Q_1 = T_1\).

\[\begin{eqnarray} \Pr(T_1 \leq t) &=& \Pr(N(t) \geq 1)\\ &=& p_1(t) + p_2(t) + \cdots\\ &=& 1 - p_0(t) \\ &=& 1 - e^{-\lambda t}. \end{eqnarray}\]

Thus, the density function \(\rho_{T_1}(t)\)of \(T_1\) is given by 

\[\rho_{T_1}(t) = \frac{d\Pr(T_1 \leq t)}{dt} = \lambda e^{-\lambda t}.\]

This is the density function of the exponential distribution with parameter \(\lambda\). Thus, \(Q_1, Q_2, \cdots\) all follow the same exponential distribution with parameter \(\lambda\). 

Simulation

Now, let's discretize the time. For some small \(\delta t > 0\), we consider the random values \(N(\delta t), N(2\delta 2), N(3\delta t), \cdots\). Since the time interval between one increment and the next follows the exponential distribution, we can determine whether to increment or not at each time step in the following manner.
  1. Generate a uniform random number \(r \in [0, 1)\).
  2. If \(r < 1 - e^{-\lambda \delta t}\), then increment by 1. Otherwise, do not increment.
The second step simply means that one increment occurs within the duration of \(\delta t\). Since the time till the increment follows the exponential distribution, its probability is \(\Pr(T_1 \leq \delta t) = 1 - e^{-\lambda \delta t}\). Thus, the algorithm for simulation is given as follows.
  1. Set \(N(0) = 0\), k = 0.
  2. Generate a uniform random number \(r \in [0, 1)\).
  3. If \(r < 1 - e^{-\lambda \delta t}\), then set \(N((k+1)\delta t) = N(k\delta t) + 1\); otherwise, set \(N((k+1)\delta t) = N(k\delta t)\).
  4. Set \(k = k + 1\). Go to step 2, and repeat.
Every time we run this simulation, a different sample path is generated. One example is shown at the top of this page. Other samples are found below.




Related resources

A Google Sheets implementation is available here.

An accompanying video is available on YouTube:



Comments

Popular posts from this blog

Open sets and closed sets in \(\mathbb{R}^n\)

Euclidean spaces

Newton's method