Advertisement
karlakmkj

Poisson distribution

Jul 26th, 2021
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. '''
  2. Poisson distribution is used to describe the number of times a certain event occurs within a fixed time or space interval.
  3. The Poisson distribution is defined by the rate parameter, symbolized by the Greek letter lambda, λ.
  4. Lambda represents the expected value — or the average value — of the distribution.
  5. '''
  6. import scipy.stats as stats
  7.  
  8. # average number of calls in our call center between 9am and 10am to be 15 calls - second parameter
  9. # What is the probability that we would see exactly 15 calls in that time frame? - first parameter
  10. # second parameter: Poisson distributed” with lambda = 15 (average)
  11. prob_15 = stats.poisson.pmf(15, 15)
  12.  
  13. print(prob_15)
  14.  
  15. # probability we would get between 7 and 9 calls?
  16. prob_7_to_9 = stats.poisson.pmf(7, 15) + stats.poisson.pmf(8, 15) + stats.poisson.pmf(9, 15)
  17.  
  18. print(prob_7_to_9)
  19.  
  20. # for a range of values use cdf
  21.  
  22. # probability of observing more than 20 calls - use 1 minus
  23. prob_more_than_20 = 1 - stats.poisson.cdf(20, 15)
  24.  
  25. print(prob_more_than_20)
  26.  
  27. # probability of observing between 17 to 21 calls
  28. prob_17_to_21 = stats.poisson.cdf(21, 15) - stats.poisson.cdf(16, 15)
  29.  
  30. print(prob_17_to_21)
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement