当我拟合威布尔分布时,在其他问题中也发现了Fitting distribution with fixed parameters in SciPy
使用floc=0
和{
weibull_params = 1, 2.0755160030790547, 0, 16.273031221223277
data = sp.stats.exponweib.rvs(*weibull_params, size=50000)
data = data.astype(int)
x = linspace(0, 55)
weibull_params1 = sp.stats.weibull_min.fit(data)
weibull_params2 = sp.stats.weibull_min.fit(data, loc=0)
weibull_params3 = sp.stats.weibull_min.fit(data, floc=0)
for weibull_params, line_style in zip([weibull_params1, weibull_params2, weibull_params3],['-','--','-.']):
plt.figure()
plt.hist(data, bins=arange(0,55),alpha=0.5, normed=True)
y_weibull = sp.stats.weibull_min.pdf(x, *weibull_params)
plot(x, y_weibull, line_style, color='black')
print(weibull_params)
会产生这样的威布尔:
威布尔参数:
^{pr2}$有什么区别?我什么时候该用哪一个?在
简单的回答是:}只给出拟合的起始值。在
floc
(和fscale
)用于指定位置参数(和比例参数)保持在指定值不变。loc
和{sp.stats.weibull_min
从scipy.stat.rv_continuous
继承fit
方法。documentation of ^{floc
和{loc
、scale
和其他由派生发行版识别的关键字参数被简单地用作起始值。在因此,如果你想保持位置不变,你应该使用
floc=0
如果你只想提供一个起始参数,你应该使用loc=0
。在相关问题 更多 >
编程相关推荐