I am using scipy.stats.expon.fit(data)
to fit an exponential distribution to my data. This appears to return two values where I would expect one. The documentation online doesn't seem to say what fit()
returns but looking at the source, I am guessing it is both a location and scale parameter. Can you fix the location parameter to 0
when doing the fitting?
scipy.stats.expon.fit() with no location parameter
Asked Answered
@mdml Thank you. I would like to run fit but have the location fixed to 0. It seems this isn't the default behaviour. (It is odd that it has a location parameter at all to be honest for the exponential distribution.) –
Tanagra
Duplicate: #21610534 (Yeah, I know I already answered. Shame on me.) –
Gegenschein
@WarrenWeckesser Ah well I will happily delete it but it would be great if the docs could be updated! –
Tanagra
In the call to expon.fit
, use floc=0
:
In [5]: data = expon.rvs(0, 1.5, 1000)
In [6]: loc, scale = expon.fit(data, floc=0)
In [7]: scale
Out[7]: 1.4878030368336586
In [8]: loc
Out[8]: 0
Thank you! Is that in the documentation anywhere? Or in other words, how did you know this? –
Tanagra
You have to read the docstring of
expon.fit
pretty closely to find it, but it is mentioned in there. Read the description of kwds
in the "Parameters" section. –
Gegenschein Oh wow. The official web page has loads less information in it than the docstring!! –
Tanagra
© 2022 - 2024 — McMap. All rights reserved.