scipy.stats.expon.fit() with no location parameter

eleanora picture eleanora · Aug 1, 2014 · Viewed 9.7k times · Source

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?

Answer

Warren Weckesser picture Warren Weckesser · Aug 1, 2014

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