Reputation: 31
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)
vals
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.
Upvotes: 3
Views: 5113
Reputation: 114781
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
Upvotes: 4