elena1234

Poisson Distribution in Python

Jul 4th, 2022 (edited)
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import seaborn as sns
  4. from scipy.stats import poisson
  5.  
  6. # If we have know that between 4:30pm and 4:45pm each weekday an average of 3.6 customers enter any given checkout line. What is the probability that exactly 7 customers enter your line between 4:30pm and 4:45pm?
  7. mu = 3.6
  8. exact_seven = 7
  9. poisson.pmf(exact_seven, mu)
  10.  
  11. seven_or_less = poisson.cdf(7,mu)
  12. seven_or_less
  13.  
  14. seven_or_most = 1 - poisson.cdf(6,mu)
  15. seven_or_most
  16.  
  17. poisson.mean(3.6)
  18.  
  19. poisson.var(3.6)
  20.  
  21. poisson.std(3.6)
  22.  
  23.  
  24. # Visualization
  25. sns.set_theme(style = 'darkgrid')
  26. x_ax = np.arange(0,11)
  27. y_ax = poisson.pmf(x_ax, 3.6)
  28. sns.barplot(x = x_ax, y = y_ax)
  29. plt.show()
  30.  
  31. y_ax = poisson.cdf(x_ax, 3.6)
  32. sns.barplot(x = x_ax, y = y_ax)
  33. plt.show()
Add Comment
Please, Sign In to add comment