1. 程式人生 > >正態分佈/最大似然估計

正態分佈/最大似然估計



from scipy.stats import norm
n1 = norm(loc=0.3, scale=1.0) #<scipy.stats.distributions.rv_frozen at 0x7fc3c45bb610>
n2 = norm(loc=0, scale=1.0)
n1.rvs(size=100) #numpy.array值
loc, scale = norm.fit(samples) #最大似然估計
x = linspace(-3,3,100)

hist([samples, n1_samples, n2_samples], normed=True)
plot(x, n.pdf(x), 'b-')
plot(x, n1.pdf(x), 'g-')
plot(x, n2.pdf(x), 'r-')

參考[資料分析經典參考
](http://nbviewer.jupyter.org/github/lijin-thu/notes-python/blob/master/04-scipy/04.03-statistics-with-scipy.ipynb)