首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用genextreme和weibull_min拟合威布尔分布

用genextreme和weibull_min拟合威布尔分布
EN

Stack Overflow用户
提问于 2016-08-04 19:21:53
回答 1查看 2.6K关注 0票数 2

使用SciPy,我试图从this question中重现威布尔拟合。当我使用genextreme函数时,我的拟合效果很好,如下所示:

代码语言:javascript
复制
import numpy as np
from scipy.stats import genextreme
import matplotlib.pyplot as plt

data=np.array([37.50,46.79,48.30,46.04,43.40,39.25,38.49,49.51,40.38,36.98,40.00,
               38.49,37.74,47.92,44.53,44.91,44.91,40.00,41.51,47.92,36.98,43.40,
               42.26,41.89,38.87,43.02,39.25,40.38,42.64,36.98,44.15,44.91,43.40,
               49.81,38.87,40.00,52.45,53.13,47.92,52.45,44.91,29.54,27.13,35.60,
               45.34,43.37,54.15,42.77,42.88,44.26,27.14,39.31,24.80,16.62,30.30,
               36.39,28.60,28.53,35.84,31.10,34.55,52.65,48.81,43.42,52.49,38.00,
               38.65,34.54,37.70,38.11,43.05,29.95,32.48,24.63,35.33,41.34])

shape, loc, scale  = genextreme.fit(data)

plt.hist(data, normed=True, bins=np.linspace(15, 55, 9))

x = np.linspace(data.min(), data.max(), 1000)
y = genextreme.pdf(x, shape, loc, scale)
plt.plot(x, y, 'c', linewidth=3)

参数为:(0.44693977076022462, 38.283622522613214, 7.9180988170857374)。形状参数是正的,对应于Weibull wikipedia page上的形状参数的符号,据我所知,它等价于R中的负形状参数?

因此,似乎genextreme自己决定分布是冈贝尔、弗雷谢特还是威布尔。在这里,它选择了威布尔。

现在,我正在尝试用weibull_min函数重现类似的拟合。我已经尝试了以下基于this post的方法,但是参数看起来与我使用genextreme得到的参数非常不同

代码语言:javascript
复制
weibull_min.fit(data, floc=0) 

现在的参数是:(6.4633107529634319, 0, 43.247460728065136)

形状参数是0吗?如果分布是威布尔的,那么它当然应该是正的?

EN

回答 1

Stack Overflow用户

发布于 2016-08-04 19:48:31

weibull_min.fit()返回的参数为(shape, loc, scale)loc是location参数。(所有的scipy发行版都包含一个location参数,即使是那些通常不使用location参数的发行版。)weibull_min.fit的文档字符串包含以下内容:

代码语言:javascript
复制
Returns
-------
shape, loc, scale : tuple of floats
    MLEs for any shape statistics, followed by those for location and
    scale.

您使用了参数floc=0,因此,不出所料,fit(data, floc=0)返回的location参数为0。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38765996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档