from IPython.display import YouTubeVideo YouTubeVideo("31MoWKnPDaU") import sympy as sym sym.init_printing() a, x, y, z = sym.symbols("a, x, y, z") expr = (1 + a/x)**x expr sym.limit(expr, x, sym.oo) approx = sym.series(sym.log(1 - z)) approx approx = approx.subs({z: -(a*y)}) approx sym.simplify((1/y) * approx) YouTubeVideo("sWAqWRPqLok") %pylab inline --no-import-all import math def poisson(lambda_, k): return lambda_**k * math.exp(-lambda_) / math.factorial(k) # Nos paramètres. lambda_ = 7 # Le nombre moyen de voitures qui passent. k = range(0,21) # Les probabilités de 0 à 20 voitures. fig = plt.figure() axes = fig.add_axes([0.1, 0.1, 0.8, 0.8]) axes.plot(k, map(lambda k: poisson(lambda_, k), k)) axes.set_xlabel("Voitures") axes.set_ylabel("Prob") axes.axvline(3, color='r') axes.set_title("Distribution Poisson") None from scipy import stats # Créer une distribution Poission avec lambda égal à 7. nv = stats.poisson(7) # Trouver la moyenne et l'écart type. nv.mean(), nv.std() def dessiner(titre, fonc, x): """Dessiner fonc(x).""" fig = plt.figure() axes = fig.add_axes([0.1, 0.1, 0.8, 0.8]) axes.plot(x, fonc(x)) axes.set_title(titre) dessiner("Distribution Poisson", nv.pmf, range(0, 21)) dessiner("Distribution Poisson (cdf)", nv.cdf, range(0, 21)) dessiner("Distribution Poisson (sf)", nv.sf, range(0, 21))