Table of Contents
Hands-On Probability and Statistics 4: Mutually Exclusive Events - Practical Exercises
Hands On: Probability and Statistics -4
Problem Statement
In each of 4 different competitions, Jin has a 60% chance of winning.
Assuming that the competitions are independent of each other, what is the
probability that: Jin will win at least 1 race. Use Binomial distribution
Note:
1. Display the probability in decimal rounded off to 2 decimal places
2. Hint: P(x>=1)=1-P(x=0)
3. Use the binom.pmf() function of scipy.stats package.
Function Description
Function Name: binomial()
1. Output:
ans: Float - Denotes the probability that Jin will win at least 1 race.
from scipy import stats
def binomial():
'''
output: ans : Float
'''
#Write your code here
#Assign the probability value to the variable ans
#Round off to 2 decimal places
p = 0.6 # probability of winning each competition
n = 4 # number of competitions
k = 1 # minimum number of competitions Jin must win
# Compute the probability using the cumulative distribution function (CDF) of the binomial distribution
# which calculates the probability of getting k or more successes in n independent trials with a
# probability p of success in each trial
ans = round(1 - stats.binom.cdf(k - 1, n, p), 2)
return ans
if __name__=='__main__':
print(binomial())
Output:
0.97