首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >指数Weibull分布上的Curve_fit失败

指数Weibull分布上的Curve_fit失败
EN

Stack Overflow用户
提问于 2018-09-25 06:22:30
回答 1查看 286关注 0票数 1

我试着用

代码语言:javascript
复制
scipy.optimize.curve_fit(func,xdata,ydata)

为了确定指数威布尔分布的参数:

代码语言:javascript
复制
#define exponentiated weibull distribution
def expweib(x,k,lamda,alpha):
      return alpha*(k/lamda)*((x/lamda)**(k-1))*((1-np.exp(-(x/lamda)*k))**(alpha-1))*np.exp(-(x/lamda)*k)


 #First generate random sample of exponentiated weibull distribution using stats.exponweib.rvs
data = stats.exponweib.rvs(a = 1, c = 82.243021128368554, loc = 0,scale = 989.7422, size = 1000 )


#Then use the sample data to draw a histogram
entries_Test, bin_edges_Test, patches_Test = plt.hist(data, bins=50, range=[909.5,1010.5], normed=True)

#calculate bin middles of the histogram
bin_middles_Test = 0.5*(bin_edges_Test[1:] + bin_edges_Test[:-1])

#use bin_middles_Test as xdata, bin_edges_Test as ydata, previously defined expweib as func, call curve_fit method:
params, pcov = curve_fit(weib,bin_middles_Test, entries_Test )

然后发生错误:

代码语言:javascript
复制
OptimizeWarning: Covariance of the parameters could not be estimatedcategory=OptimizeWarning)

我不知道哪一步有问题,有人能帮忙吗?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2018-09-25 07:05:09

在这里阅读curve_fit方法的文档,fit.html,关于方法参数,他们提到了the default 'lm' method won't work if the number of observations is less than the number of variables, in which case you should use either of *'trf'* or *'dogbox'* method

此外,阅读返回值部分中关于“pcov”的内容时,他们提到如果是the Jacobian matrix at the solution does not have a full rank,条目将是inf。

我用trf和dogbox尝试了您的代码,得到了充满零的pconv数组。

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

https://stackoverflow.com/questions/52491800

复制
相关文章

相似问题

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