[SciPy-User] MLE with stats.lognorm

Christian K. ckkart@hoc....
Mon Oct 10 09:26:52 CDT 2011


> >> for example with starting value for loc
> >>>>> print stats.lognorm.fit(x, loc=0)
> >> (0.23800805074491538, 0.034900026034516723, 196.31113801786194)
> >
> > I see. Is there any workaround/patch to force loc=0.0? What is the
> > meaning of loc anyway?
> 
> loc is the starting value for fmin, I don't remember how to specify
> starting values for shape parameters, I never used it.
>
> As in the ticket you could monkey patch the _fitstart function
> 
> >>> stats.cauchy._fitstart = lambda x:(0,1)
> >>> stats.cauchy.fit(x)
> 
> or what I do to experiment with starting values is
> 
> stats.distributions.lognorm_gen._fitstart = fitstart_lognormal

Ok, but this is not different from calling fit like
stats.lognorm.fit(samples, loc=0.0)

I would really need to force loc=0.0

stats.lognorm.fit(samples, loc=0.0, floc=0.0)

does not work either.

Btw., I think the extradoc is quite misleading:

"""
lognorm.pdf(x,s) = 1/(s*x*sqrt(2*pi)) * exp(-1/2*(log(x)/s)**2)
for x > 0, s > 0.

If log x is normally distributed with mean mu and variance sigma**2,
then x is log-normally distributed with shape paramter sigma and scale
parameter exp(mu).
"""

sigma seems to equal s in the function definition but mu does not appear at 
all. It seems to enter via _pdf()/scale when looking at distributions.py, 
wehere scale = exp(mu)?

Christian




More information about the SciPy-User mailing list