for $k = 0, 1, 2, ..., n$.
#determine distribution
#consider 10 free throw attempts with p = .5
ft = stats.binom(10, 0.5)
#plot probability
plt.bar(range(11), ft.pmf(range(11)))
#probability of 6 successes?
ft.pmf(6)
#probability of at least 6 made?
ft.pmf(6) + ft.pmf(7) + ft.pmf(8) + ft.pmf(9) + ft.pmf(10)
#with cumulative distribution function
1 - ft.cdf(5)
#Example 2: p = 0.8, n = 20
ex2 = stats.binom(20, 0.8)
#P(10)
ex2.pmf(10)
plt.bar(range(21), ex2.pmf(range(21)))
#P(n > 14)
1 - ex2.cdf(13)
#mean of a list
x = [3, 5, 7, 9, 11]
np.mean(x)
#standard deviation of list
np.std(x)
#Binomial distribution with n = 20, p = 0.5
b = stats.binom(20, 0.5)
#mean
b.mean()
#plot
plt.bar(range(21), b.pmf(range(21)))
#another example
#Binomial n = 50, p = 0.3
ex2 = stats.binom(50, 0.3)
ex3 = stats.binom(20, 0.3)
#mean
ex2.mean()
ex3.mean()
ex3.std()
#deviation
ex2.std()
#plot
plt.bar(range(51), ex2.pmf(range(51)))
plt.bar(range(21), ex3.pmf(range(21)))
#determine distribution
##Average height of 60 inches, s.d 2
heights = stats.norm(60, 2)
#define domain
x = np.linspace(54, 66, 1000)
#plot distribution
plt.plot(x, heights.pdf(x))
#probability of 65 inches?
heights.pdf(65)
#probability less than 50?
heights.cdf(60)
heights.mean()
heights.std()