Scipy Weibull CDF calculation

戏子无情 提交于 2020-01-01 06:57:06

问题


I'm doing survival calculations in Scipy and can't get the correct values.

My code:

x, a, c = 1000, 1.5, 5000

vals = exponweib.cdf(x,a,c,loc=0,scale=1)

Val should equal 0.085559356392783004, but I'm getting 0 instead.

If I define my own function I get the right answer: def weibCumDist(x,a,c): return 1-np.exp(-(x/c)**a)

I could just use my own function, but I'm curious as to what I'm doing wrong. Any suggestions?

Thanks.


回答1:


You haven't correctly mapped your parameters to those of scipy. To implement the equivalent of your weibCumDist:

In [22]: x = 1000

In [23]: a = 1.5

In [24]: c = 5000

In [25]: exponweib.cdf(x, 1, a, loc=0, scale=c)
Out[25]: 0.08555935639278299

Note that exponweib is the exponentiated Weibull distribution.

You probably want to use scipy.stats.weibull_min. This is the implementation of the distribution that is often referred to as "the" Weibull distribution:

In [49]: from scipy.stats import weibull_min

In [50]: weibull_min.cdf(x, a, loc=0, scale=c)
Out[50]: 0.08555935639278299


来源:https://stackoverflow.com/questions/27432222/scipy-weibull-cdf-calculation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!