lognormal fit

30 views
Skip to first unread message

Daniele Notarmuzi

unread,
Feb 2, 2020, 4:36:13 PM2/2/20
to powerlaw...@googlegroups.com
Hello.

I am using the package to fit some data. My data are discrete positive integers, whose minimum value is 1.

I fit my data to a powerlaw and then I want to check if the lognormal is a better fit. It happens that the parameters found by the lognormal fit are

mu = -40.

This I don't understand: the maximum likelihood parameters of a lognormal distribution are known analytically and they are not even close to what I get. How is this possible?

More specifically: I have been taking a look at the code and I saw that it uses scipy.fmin to find optimal parameters. How can fmin find something SO different from the exact result? and even less clear: why should one call fmin given that an exact solution is known?

Let me conclude by noting that the mu I find is smaller than mean(log(data)), which I see shoulf not be allowed by the lognormal_likelihood_generator.

Do you have any clue on what is going on and how should I interpret my results? 

Thank you in advance.
Best,
DN.

Jeff Alstott

unread,
Feb 2, 2020, 4:43:41 PM2/2/20
to powerlaw...@googlegroups.com
Hi Daniele,

Is the concern that mu is negative? If so, there's a whole writeup of the conceptual issue in both the paper and in the Github readme: https://github.com/jeffalstott/powerlaw#power-laws-vs-lognormals-and-powerlaws-lognormal_positive-option

If you know of an analytic solution for a lognormal under the various conditions (e.g. only positive integers), then please add it as a pull request!

Thanks,
Jeff

--
You received this message because you are subscribed to the Google Groups "powerlaw-general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to powerlaw-gener...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/powerlaw-general/CACRGUqdU%3DDkMuEsCmufiQWoKRkE6eQ9sv53hjo29xsZ3FxDbog%40mail.gmail.com.

Daniele Notarmuzi

unread,
Feb 2, 2020, 5:24:17 PM2/2/20
to powerlaw...@googlegroups.com
Let me further add what follows:

I copied and paste the following functions from the original code to my notebook:

likelihood_function_generator
lognormal_likelihoods

Then I do what follows:

- initialize parameters mu and sigma to their ML values (as done in the original code, right?)
- likelihood_function_generator('lognormal', args)
- parameters, negative_loglikelihood, iter, funcalls, warnflag, = \
    fmin(
        lambda p: -sum(np.log(likelihood_function(p, data))),
        param, full_output=1, disp=False)


The output of fmin is... the maximum likelihood estimators.

But if I just call powerlaw.Fit(data, 'lognormal', args) I get completely different values.

What is the fit function doing that I am missing?

Thank you in advance.
Best,
DN.

Jeff Alstott

unread,
Feb 2, 2020, 5:47:38 PM2/2/20
to powerlaw...@googlegroups.com
I didn't parse what you did, but did you not threshold your data above xmin before fitting? powerlaw fits all distributions only on the data above xmin.

--
You received this message because you are subscribed to the Google Groups "powerlaw-general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to powerlaw-gener...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages