Scipy Weibull CDF计算 [英] Scipy Weibull CDF calculation
问题描述
我正在Scipy中进行生存率计算,无法获得正确的值.
I'm doing survival calculations in Scipy and can't get the correct values.
我的代码:
x,a,c = 1000,1.5,5000
x, a, c = 1000, 1.5, 5000
vals = exponweib.cdf(x,a,c,loc = 0,scale = 1)
vals = exponweib.cdf(x,a,c,loc=0,scale=1)
Val应该等于0.085559356392783004,但我却改为0.
Val should equal 0.085559356392783004, but I'm getting 0 instead.
如果我定义自己的函数,则会得到正确的答案: def weibCumDist(x,a,c): 返回1-np.exp(-(x/c)** a)
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?
谢谢.
推荐答案
您尚未正确将参数映射到scipy的参数.要实现与您的weibCumDist
相同的内容:
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.
您可能想使用scipy.stats.weibull_min
.这是通常称为威布尔分布"的分布的实现:
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
这篇关于Scipy Weibull CDF计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!