Search This Blog

Python - Mutually Exclusive Events - Probability and Statistics -4 - HackerRank Fresco Play Hands On

 1. 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 



Answer: 

from scipy import stats

def binomial():
    '''
    output: ans : Float
    '''
    #Write your code here
    n = 0
    p = 4
    k = 0.60
    prob = stats.binom.pmf(n,p,k)
    ans = round(1-prob,2)
    #Assign the probability value to the variable ans
    actuall = 1 - prob
    #Round off to 2 decimal places
    return ans

if __name__=='__main__':
    print(binomial())




No comments:

Post a Comment

If you have any doubts, Please let us know.