Learning Notes, Python

Stochastic – Poisson Process with Python example

Poisson Distribution

The Poisson distribution is in fact originated from binomial distribution, which express probabilities of events counting over a certain period of time. When this period of time becomes infinitely small, the binomial distribution is reduced to the Poisson distribution. The proof can be found here.

The Poisson Distribution can be formulated as follow:

\displaystyle P(X=k)=\frac{\lambda ^k e^{-\lambda}}{k!}, k \in \mathbb{Z}^+

where X is a random variable.

Poisson

Figure 1. Poisson Distribution

Poisson Process

Definition

For a random process X(t) , it is identified as a Poisson process if it satisfy the following conditions:

  1. X(0) = 0
  2. Each incremental process are independent (i.e. It is a Markov process)
  3. P(X(t)=k) = [(\lambda t)^k e^{-\lambda t}]/k!

One can think of it as an evolving Poisson distribution which intensity λ scales with time (λ becomes λt) as illustrated in latter parts (Figure 3).

Note: If λ stays constant for all t then the process is identified as a homogeneous Poisson process, which is stationary process.

Example – Simulation of Poisson processes

Similar to the case in random walk, the Poisson process \{X(t) \in \mathbb{Z}^+; t \in T\} can be formulated as follow [Eq.1]:

\displaystyle X(t) = X_0 + \sum_{i=1}^{t} X_i

where by definition we requires X_0 to be zero.

import numpy as np
import matplotlib.pyplot as plt

# Prepare data
N = 50 # step
lambdas = [1, 2, 5]
X_T = [np.random.poisson(lam, size=N) for lam in lambdas]
S = [[np.sum(X[0:i]) for i in xrange(N)] for X in X_T]
X = np.linspace(0, N, N)

# Plot the graph
graphs = [plt.step(X, S[i], label="Lambda = %d"%lambdas[i])[0] for i in xrange(len(lambdas))]
plt.legend(handles=graphs, loc=2)
plt.title("Poisson Process", fontdict={'fontname': 'Times New Roman', 'fontsize': 21}, y=1.03)
plt.ylim(0)
plt.xlim(0)
plt.show()

PoissonProcess

Figure 2. Poisson Process, k against t

Further Elaboration of results

To show the upper process follows definition 3, which said [Eq.2]:

\displaystyle P(X(t)=k) = \frac{(\lambda t)^k e^{-\lambda t}}{k!}

the graph P( X(t) = k ) against t is plotted w.r.t. different values of λ.

Sees each peaks of different k at different t is actually the expected value of the Poisson process at the same t in Figure 2, it can also be interpreted as the most possible k at time t. An annotated comparison is provided below:

Evolution of Poisson process

The following animation shows how the probability of a process X(t) = k evolve with time. One can observe two main features:

  1. The probability distribution spread wider as time passes.
  2. The peak of the probability distribution shifts as time passes, correspond to the simulation in Figure 2.

where both features are actually governed by definition 3 [Eq.2].

PoissonSimulation

Figure 3. Evolution of Poisson Process

See Also

Stochastic Process
Stochastic – Python Example of a Random Walk Implementation
Stochastic – Stationary Process Stochastic
Python – Matplotlib – Saving animation as .gif files

Advertisements

9 thoughts on “Stochastic – Poisson Process with Python example

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s