正态分布:
os.chdir("../ch03")
#P64 normal distribution
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
%matplotlib inline
def normal(mean = 0, var = 1):
sigma = np.sqrt(var)
x = np.linspace(-3,3,100)
plt.plot(x,mlab.normpdf(x,mean,sigma))
plt.show()
normal(1,0.5)
二项分布
#P65 binomial
from scipy.stats import binom
def binomial(x=10,n=10, p=0.5):
fig, ax = plt.subplots(1, 1)
x=range(x)
rv = binom(n, p)
plt.vlines(x, 0, (rv.pmf(x)), colors='k', linestyles='-')
plt.show()
binomial()