This notebook explores the poisson distribution
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import binom, norm, poisson
Poisson distribution with $\mu = 1$.
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$)
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)];
Same but with $\mu = 0.5$.
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)$.
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()
plt.bar(x, 100*(bf-pf))
plt.xlabel('Events')
plt.ylabel('Prob. Diff. (Binom - Poisson) (%)')
plt.show()
Poisson at $\mu = 25$ comparison to Gaussian
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()
plt.bar(x, 100*(pf-gf))
plt.xlabel('Events')
plt.ylabel('Prob. Diff. (Binom - Norm) (%)')
plt.show()