0

In each of 4 different competitions, Jin has 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.

Binomial Distribution Parameters:

n=4    
p=0.60

Display the probability in decimal.

Hint:

  1. P(x>=1)=1-P(x=0)
  2. Use the binom.pmf() function of scipy.stats package to calculate the probability.
#n=4
#p=0.60
#k=1

from scipy import stats
probability=stats.binom.pmf(1,4,0.60)
print(probability)

#0.15360000000000007

What should be the value of K here. My output is not correct.

morgan121
  • 2,213
  • 1
  • 15
  • 33
rohit Rohit
  • 11
  • 1
  • 1
  • 1

4 Answers4

3

I will first explain the solution in Mathematical Terms:

The Probability that Jin will win atleast 1 race = 1 - Jin will win NO race

In each of the 4 races Jin has 60 percent chance of winning. That means he has 40 percent chance of losing.

If the probability of success on an individual trial is p, then the binomial probability of n repeated trials with x successes is nCx⋅p^x⋅(1−p)^n−x

Hence, the Probability that Jin will win No race out of the 4 races = 4C0 X 0.6^0 X 0.4^4 = 0.0256

Hence, the Probability that Jin will win atleast 1 race = 1 - 0.0256 = 0.9744‬

The Code:

from scipy import stats

def binomial():
    ans = 1 - round(stats.binom.pmf(0,4,0.6),2)
    return ans

if __name__=='__main__':
    print(binomial())
1
#n=4
#p=0.60
#k=1
from scipy import stats
//P(x>=1)=1-P(x=0) this means 1.first find probability with k=0 

probability=stats.binom.pmf(0,4,0.60)
//then do 1- probability
actual_probability=1-probability
print(actual_probability)
shebeena
  • 11
  • 2
0
from scipy import stats
from scipy.stats import binom
def binomial():
n=4
p=0.6
k=0
prob =binom.pmf(k,n,p)
ans =round(1-prob,2)
#Round off to 2 decimal places
return ans
  • 6
    Please don't post only code as answer, but also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes. – Jan Feb 21 '21 at 11:10
0

def binomial():
    li=[1,2,3,4]
    lis=[stats.binom.pmf(k,4,0.6) for k in li]
    an=sum(lis)
    ans=round(an,2)
    return ans

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