Python Puzzles
If my super fancy puzzle website averages 12 visitors a day, what are the chances of….
Getting exactly 10 visitors a day?
Getting 10 or more visitors a day?
You will need to use a Poisson distribution to solve this problem.
The probability of getting exactly 10 visitors a day is 10%
The probability of getting 10 or more visitors a day is 75%
The code is pretty simple using Numpy.
size = 1_000_000
lam = 12
import numpy as np
np_poisson = np.random.poisson(lam=lam, size=size)
#the probability of getting exactly 10 in a Poisson distribution
filter = np_poisson == 10
new_arr = np_poisson[filter]
print(np.size(new_arr)/size)
#the probability of getting exactly 10 or more in a Poisson distribution
filter = np_poisson >= 10
new_arr = np_poisson[filter]
print(np.size(new_arr)/size)