首先,我认为您可能希望将位置参数固定在0。在
其次,你的数据中有0,结果拟合可能在x=0处有{}pdf,例如对于GEV拟合或Weibull拟合。
因此,拟合实际上是正确的,但是当绘制pdf(包括x=0)时,得到的曲线图是扭曲的。在
第三,我真的认为scipy应该放弃对x=0的支持,比如Weibull。对于x=0,R给出了一个很好的Error in fitdistr(data, "weibull") : Weibull values must be > 0的警告,这很有帮助。在In [103]:
p=ss.genextreme.fit(data, floc=0)
ss.genextreme.fit(data, floc=0)
Out[103]:
(-1.372872096699608, 0, 0.011680600795499299)
In [104]:
plt.hist(data, bins=20, normed=True, alpha=0.7, label='Data')
plt.plot(np.linspace(5e-3, 1.6, 100),
ss.genextreme.pdf(np.linspace(5e-3, 1.6, 100), p[0], p[1], p[2]), 'r ',
label='GEV Fit')
plt.legend(loc='upper right')
plt.savefig('T1.png')