Python 用genextreme和Weibull_min拟合Weibull分布
使用SciPy,我试图从中重现weibull拟合。当我使用Python 用genextreme和Weibull_min拟合Weibull分布,python,r,scipy,distribution,weibull,Python,R,Scipy,Distribution,Weibull,使用SciPy,我试图从中重现weibull拟合。当我使用genextreme功能时,我的身材看起来很好,如下所示: 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,3
genextreme
功能时,我的身材看起来很好,如下所示:
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.44693977070602462、38.28362522613214、7.9180988170857374)
。形状参数是正的,对应于形状参数的符号,据我所知,其上的形状参数等同于R中的负形状参数
因此,似乎genextreme本身决定了分布是Gumbel、Frechet还是Weibull。在这里,它选择了威布尔
现在,我正试图复制一个类似的函数拟合。我尝试了以下基于的参数,但参数看起来与我使用genextreme
获得的参数非常不同:
weibull_min.fit(data, floc=0)
现在的参数是:(6.4633107529634319,0,43.247460728065136)
0
是形状参数吗?如果分布是威布尔分布,那么它肯定应该是正的。由Weibull\u min.fit()
返回的参数是(形状、位置、比例)
loc
是位置参数。(所有scipy分布包括一个位置参数,即使是那些通常不使用位置参数的分布。)weibull_min.fit
的文档字符串包括:
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)
返回的位置参数是0。因此,我使用weibull_min.fit()得到的形状参数是6.46。这与genextreme的0.44非常不同。43的比例参数不是很高吗?如何使用weibull_min.fit()将曲线拟合到数据中?关于值:weibull_min.fit(data,floc=0)
返回的值与R中的fitdire(mydata,“weibull”)
返回的值非常接近,如您在链接的问题中所见。无耻的插件:paramnormal可能会帮助您: