Exercise 1

Question: 5 coins were tossed, what is the probability that at least 2 of them will get head.

In [1]:
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

In [4]:
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
In [6]:
prob_of_gettting_max_1_head
Out[6]:
0.18749999999999994
In [7]:
prob_of_gettting_atleast_2_head = 1 - prob_of_gettting_max_1_head
In [8]:
prob_of_gettting_atleast_2_head
Out[8]:
0.8125

Second Approach - cumulative distribution function

In [12]:
Cumulative_prob_of_gettting_max_1_head = binom.cdf(1, n, p)
In [13]:
Cumulative_prob_of_gettting_max_1_head
Out[13]:
0.1875

Exercise 2

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 in

In [14]:
from scipy.stats import poisson
In [15]:
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

In [16]:
prob_of_getting_more_than_350_calls = 1- prob_of_350_or_less_calls
In [17]:
prob_of_getting_more_than_350_calls
Out[17]:
0.002196653446150054