正态分布/最大似然估计
程序员文章站
2022-07-11 15:34:05
...
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)
下一篇: 统计学的Python实现-006:方差