【发布时间】:2018-08-14 06:45:57
【问题描述】:
我有一些数据,我使用 scipy.stats.normal 对象拟合函数拟合正态分布,如下所示:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
import matplotlib.mlab as mlab
x = np.random.normal(size=50000)
fig, ax = plt.subplots()
nbins = 75
mu, sigma = norm.fit(x)
n, bins, patches = ax.hist(x,nbins,normed=1,facecolor = 'grey', alpha = 0.5, label='before');
y0 = mlab.normpdf(bins, mu, sigma) # Line of best fit
ax.plot(bins,y0,'k--',linewidth = 2, label='fit before')
ax.set_title('$\mu$={}, $\sigma$={}'.format(mu, sigma))
plt.show()
我现在想提取拟合的 mu 和 sigma 值中的不确定性/误差。我该怎么办?
【问题讨论】:
标签: python statistics curve-fitting gaussian data-fitting