import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp
X = np.arange(0,21)
plt.rc('text', usetex = True)
plt.rc('font', family = 'serif', size = 12)
##
## CDF
##
col = {1: 'orange', 4: 'purple', 10: 'lightblue'}
plt.clf()
plt.figure(figsize=(4,3.2))
plt.axes([0.17,0.13,0.79,0.8])
A = []
for L in 1,4,10:
P = -L + X*np.log(L) - sp.gammaln(X+1)
P = np.exp(P)
P = np.cumsum(P)
for k in range(1,len(X)):
plt.plot([k-1,k], [P[k-1],P[k-1]], '-', color='grey', label = '_nolegend_')
a = plt.plot(X, P, 'o', color=col[L], markeredgecolor='k', markeredgewidth=0.5)
A.append(a)
plt.xlabel("$k$")
plt.ylabel(u"$P(X\le k)$")
bx = plt.legend((r"$\lambda=1$", r"$\lambda=4$", r"$\lambda=10$"),\
numpoints=1, handletextpad=0, loc="lower right")
bx.draw_frame(False)
plt.xlim([-1,21])
plt.ylim([0,1])
plt.savefig("poisson_cdf.pdf")
plt.savefig("poisson_cdf.svg")