Example 2: Binomial distribution, n=6
import matplotlib.pyplot as plt
from scipy.stats import binom
import os
os.chdir('C:\\Anaconda\\mycodes\\aerospace')
os.getcwd()
fig,ax = plt.subplots(1,1)
x = [0,1,2,3,4,5,6]
n,p = 6,0.5
rv = binom(n,p)
ax.vlines(x,0,rv.pmf(x),colors='k',linestyles='-',lw=1,label='Probability')
ax.legend(loc='best',frameon=False)
plt.savefig("example2.png", dpi=100)
plt.show()
plt.close()
Plot:
Recent Comments