[SciPy-User] MLE with stats.lognorm

josef.pktd@gmai... josef.pktd@gmai...
Sun Oct 9 07:06:32 CDT 2011


On Sun, Oct 9, 2011 at 7:51 AM, Christian K. <ckkart@hoc.net> wrote:
> Hi,
>
> I wonder whether I am doing something wrong or if the following is to be
> expected (using sciyp 0.9):
>
> In [38]: from scipy import stats
>
> In [39]: dist = stats.lognorm(0.25,scale=200.0)
>
> In [40]: samples = dist.rvs(size=100)
>
> In [41]: print stats.lognorm.fit(samples)
> C:\Python26\lib\site-packages\scipy\optimize\optimize.py:280: RuntimeWarning:
> invalid value encountered in subtract
>  and max(abs(fsim[0]-fsim[1:])) <= ftol):
> (1.0, 158.90310231282845, 21.013288720647015)
>
> In [42]: print stats.lognorm.fit(samples, floc=0)
> [2.2059200167655884, 0, 21.013288720647015]
>
> Even when fixing loc=0.0, the results from the MLE for s and scale are very
> different from the input parameters. Is lognorm
>
> Any hints are highly appreciated.

I just looked at similar cases, for the changes in scipy 0.9 and
starting values, see
http://projects.scipy.org/scipy/ticket/1530

Essentially, you need to find better starting values and give it to fit.

Can you add it to the ticket? It's not quite the same, but I guess it
is also that fix_loc_scale doesn't make sense.

Note, I also get many of these warnings,

> invalid value encountered in subtract
>  and max(abs(fsim[0]-fsim[1:])) <= ftol):

they are caused when np.inf is returned for invalid arguments. In many
cases optimize.fmin evaluates parameters that are not valid, but most
of the time that doesn't seem to cause any problems, exept it's
annoying.

Josef


>
> Best regards, Christian
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list