โ† Back to Lessons
Open in Colab

Binomial Distribution With Python

Probability Mass Function: Binomial Distributionยถ

f(k,n,p)=Prโก(k;n,p)=Prโก(X=k)=(nk)pk(1โˆ’p)nโˆ’k\displaystyle f(k,n,p)=\Pr(k;n,p)=\Pr(X=k)={\binom {n}{k}}p^{k}(1-p)^{n-k}

for k=0,1,2,...,nk = 0, 1, 2, ..., n.

Inย [ย ]:
#determine distribution
#consider 10 free throw attempts with p = .5
Inย [ย ]:
#plot probability
Inย [ย ]:
#probability of 6 successes?
Inย [ย ]:
#probability of at least 6 made?
Inย [ย ]:
#with cumulative distribution function
Inย [ย ]:
#Example 2: p = 0.8, n = 20
Inย [ย ]:
#P(10)
Inย [ย ]:

Inย [ย ]:
#P(n > 14)