I was totally confused by fitting a weibull distribution, by
weibull_params = sp.stats.exponweib.fit(df.speed, floc=0, f0=1)
# Returns (1, 1.7358162061451901, 0, 9.4955614228786978)
How do these params correspond to the Weibull Distribution in https://en.wikipedia.org/wiki/Weibull_distribution ? Specifically, what is a
, c
in wiki's lambda
and k
?
In http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.exponweib.html#scipy.stats.exponweib , the pdf
is defined as
exponweib.pdf(x, a, c) =
a * c * (1-exp(-x**c))**(a-1) * exp(-x**c)*x**(c-1)
But in Wikipedia, the PDF is
Also, I get different result if I use exponweib.pdf
with the params it returns
df['speed'].hist(bins=arange(0, df.speed.max()), alpha=0.5, normed=True)
def weib(x,lamb,k):
return (k / lamb) * (x / lamb)**(k-1) * np.exp(-(x/lamb)**k)
k_shape, lamb_scale = weibull_params[1], weibull_params[3]
plt.plot(x, weib(x, lamb_scale, k_shape), label='self-defined weibull')
plt.plot(x, sp.stats.exponweib.pdf(x, k_shape, lamb_scale, loc=0, scale=1),'--', label ='custom_order')
plt.legend()