Poisson Distribution

This notebook explores the poisson distribution

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import binom, norm, poisson

Poisson distribution with $\mu = 1$.

In [2]:
mu = 1.
x = range(0,6)
pf = poisson.pmf(x, mu)

plt.bar(x,pf)
plt.xlabel('Events')
plt.ylabel('Prob.')
plt.show()

Very small probabilities ($\mu = 0.1$)

In [3]:
mu = 0.1
x = range(0,4)
pf = poisson.pmf(x, mu)

plt.bar(x,pf)
plt.xlabel('Events')
plt.ylabel('Prob.')
plt.show()

[print(x, p) for (x,p) in zip(x, pf)];
0 0.9048374180359595
1 0.09048374180359597
2 0.004524187090179801
3 0.00015080623633932676

Same but with $\mu = 0.5$.

In [4]:
mu = 0.5
x = range(0,6)
pf = poisson.pmf(x, mu)

plt.bar(x,pf)
plt.xlabel('Events')
plt.ylabel('Prob.')
plt.show()

Comparison of Poisson with $\mu = 2$ to Binomial with $n = 100$ and $p = 0.02$ $(np = 2)$.

In [13]:
mu = 2.0
x = range(0,10)
pf = poisson.pmf(x, mu)

n = 100
p = 0.02
bf = binom.pmf(x,n,p)

plt.bar(x,bf, label="Binomial")
plt.xlabel('Events')
plt.ylabel('Prob.')
plt.plot(x, pf,'ro', label="Poisson")
plt.legend()
plt.show()
In [14]:
plt.bar(x, 100*(bf-pf))
plt.xlabel('Events')
plt.ylabel('Prob. Diff. (Binom - Poisson) (%)')
plt.show()

Poisson at $\mu = 25$ comparison to Gaussian

In [15]:
mu = 15.
x = range(0,45)
pf = poisson.pmf(x, mu)

sigma = np.sqrt(mu)
gf = norm.pdf(x, mu, sigma)

plt.bar(x,pf)
plt.plot(x,gf,'r')

plt.xlabel('Events')
plt.ylabel('Prob.')
plt.show()
In [16]:
plt.bar(x, 100*(pf-gf))
plt.xlabel('Events')
plt.ylabel('Prob. Diff. (Binom - Norm) (%)')
plt.show()
In [ ]: