As I'm fitting a Weibull distribution, and also find in other questions as Fitting distribution with fixed parameters in SciPy
There is a difference between fit using floc=0
, and loc=0
weibull_params = 1, 2.0755160030790547, 0, 16.273031221223277
data = sp.stats.exponweib.rvs(*weibull_params, size=50000)
data = data.astype(int)
x = linspace(0, 55)
weibull_params1 = sp.stats.weibull_min.fit(data)
weibull_params2 = sp.stats.weibull_min.fit(data, loc=0)
weibull_params3 = sp.stats.weibull_min.fit(data, floc=0)
for weibull_params, line_style in zip([weibull_params1, weibull_params2, weibull_params3],['-','--','-.']):
plt.figure()
plt.hist(data, bins=arange(0,55),alpha=0.5, normed=True)
y_weibull = sp.stats.weibull_min.pdf(x, *weibull_params)
plot(x, y_weibull, line_style, color='black')
print(weibull_params)
would produce the Weibull like these:
Weibull params:
(0.50240047370945606, -4.501644985259555e-28, 2.9918077253782287)
(2.0610053128948245, -0.45099484072568979, 16.299110670854041) #loc=0
(1.0, 0, 1.05) #floc=0
What is the difference? When should I use which one?