Search code examples
pythonpower-law

How good is the fit? Python Powerlaw Package


I have made a powerlaw fit to my data with python package powerlaw with a simple: powerlaw.Fit(Weights, xmin= min(Weights)) where Weights is my data. I have used distribution_compare and obtained that lognormal is the best fit. But now I would like to know how good is this fit, not in comparison to other distributions but by itself. Is there any method in the package that can tell me such thing? How is it implemented with the data? Thanks in advance.


Solution

  • The package powerlaw does not have any method to directly compute the p-value of the fit. (As is the case for the MatLab functions used by a. Clauset et al. 2009)

    There is another Python implementation of Clauset et al. 2009, which has a function that can be used to compute the p-value. It can be found on github. The function is plpva.

    However, the function plpva is very slow and can give misleading results. See an issue with it.

    Read more about the methods used in powerlaw in Clauset et al. 2009.