Question: 5 coins were tossed, what is the probability that at least 2 of them will get head.
p = 0.5 # probability of getting head
n = 5 # Total number of coins
If you look at the question, its asking for atleast(minimum) 2 heads, and not for maximum. So, we will calculate probability of getting maximum 1 head. Then we will subtract this probability from 1, to get the probability of getting minimum 2 heads.
First Approach - probabillity mass function
from scipy.stats import binom
prob_of_gettting_0_head = binom.pmf(0, n, p)
prob_of_gettting_1_head = binom.pmf(1, n, p)
prob_of_gettting_max_1_head = prob_of_gettting_0_head + prob_of_gettting_1_head
prob_of_gettting_max_1_head
prob_of_gettting_atleast_2_head = 1 - prob_of_gettting_max_1_head
prob_of_gettting_atleast_2_head
Second Approach - cumulative distribution function
Cumulative_prob_of_gettting_max_1_head = binom.cdf(1, n, p)
Cumulative_prob_of_gettting_max_1_head
Question: In a call center, around 300 calls are handled daily. Call center employees can handle 350 calls per day. What is the probability that calls can go beyond 350 and extra employees need to be hired.
λ = 300 - Mean number of occurrences of an event in a period
x = 350 - Number of occurrences we are interested infrom scipy.stats import poisson
prob_of_350_or_less_calls = poisson.cdf(350, 300) # Cumulative density function
We have to find probability of more than 15 occurence, so we will substract it from 1
prob_of_getting_more_than_350_calls = 1- prob_of_350_or_less_calls
prob_of_getting_more_than_350_calls