In this lab, we'll put our knowledge of the Poisson Distribution to use to answer solve some sample real-world problems!
You will be able to:
- Understand and explain the Poisson Distribution and its use cases.
Solve the following sample problems by using python and your knowledge of the Poisson Distribution.
Good Data Scientists plan ahead! Since you're going to be solving Poisson Distribution problems in this lab, it's probably a good idea to write a function that calculates Poisson Probability for us first.
Recall that the Poisson Probability Formula is:
Write a generalized that takes in the appropriate parameters and returns the Poisson Probability.
NOTE: You can use np.exp()
to quickly calculate math.factorial
(from the math
library, not numpy) to calculate factorials.
HINT: It's up to you whether or not you have your function calculate the value for lambda given
import numpy as np
from math import factorial
def poisson_probability(lambd, x):
pass
A fireman fights, on average, 4 fires per month. What is the probability that a fireman is called to two different fires this week?
lambd_q1 = None
prob_q1 = None
print(prob_q1) # Expected Output: 0.18393972058572117
A car salesman sells an average of 4 cars per week. What is the probability they sell a car today?
lambd_q2 = None
prob_q2 = None
print(prob_q2) # Expected Output: 0.32269606971871956
A website makes an average of 50 sales per day. What is the probability that they make 3 sales in an hour?
lambd_q3 = None
prob_q3 = None
print(prob_q3) # Expected Output: 0.18764840049328912
A factory produces 250 cars per week (assume that the factory runs day and night all week with no down time). What is the probability that they produce 3 cars in the next hour?
lambd_q4 = None
prob_q4 = None
print(prob_q4) # Expected Output: 0.1240136186052091
The following table shows the number of houses sold by a realtor each week for the month of May. What is the probability that they sell 3 houses next week?
Week | Houses Sold |
---|---|
1 | 6 |
2 | 2 |
3 | 5 |
4 | 4 |
mean_weekly_sales = None
lambd_q5 = None
prob_q5 = None
print(prob_q5) # Expected Output: 0.18250047186175347
In this lab, we got some practice making use of our knowledge of the Poisson Distribution to answer some real-world questions!