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 λ>0, we have the probability distribution given by

pn(t)=Pr(N(t)=n)=(λt)neλtn!.

We assume that N(0)=0 almost surely. The value of N(t) increases by 1 over random periods of time. Let Tn denote the time at which N(t) becomes n. Then, T1,T2,,Tn, are random variables. Next, let's define Qn=TnTn1. Of course, we assume T0=0; accordingly, Q1=T1. Since the Poisson process is a Markov process, Q1,Q2,, are i.i.d. (independent and identically distributed). Let's calculate the cumulative distribution function of Q1=T1.

Pr(T1t)=Pr(N(t)1)=p1(t)+p2(t)+=1p0(t)=1eλt.

Thus, the density function ρT1(t)of T1 is given by 

ρT1(t)=dPr(T1t)dt=λeλt.

This is the density function of the exponential distribution with parameter λ. Thus, Q1,Q2, all follow the same exponential distribution with parameter λ

Simulation

Now, let's discretize the time. For some small δt>0, we consider the random values N(δt),N(2δ2),N(3δt),. 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[0,1).
  2. If r<1eλδt, then increment by 1. Otherwise, do not increment.
The second step simply means that one increment occurs within the duration of δt. Since the time till the increment follows the exponential distribution, its probability is Pr(T1δt)=1eλδt. Thus, the algorithm for simulation is given as follows.
  1. Set N(0)=0, k = 0.
  2. Generate a uniform random number r[0,1).
  3. If r<1eλδt, then set N((k+1)δt)=N(kδt)+1; otherwise, set N((k+1)δt)=N(kδ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

Birth process

Branching processes: Mean and variance

Informal introduction to formal logic