powerlaw is a toolbox using the statistical methods developed in Clauset et al. 2007 and Klaus et al. 2011 to determine if a probability distribution fits a power law. Academics, please cite as:
Jeff Alstott, Ed Bullmore, Dietmar Plenz. (2013). powerlaw: a Python package for analysis of heavy-tailed distributions. arXiv:1305.0215 [physics.data-an]
For the simplest, typical use cases, this tells you everything you need to know.:
import powerlaw data = array([1.7, 3.2 ...]) #data can be list or Numpy array results = powerlaw.Fit(data) print results.power_law.alpha print results.power_law.xmin R, p = results.distribution_compare('power_law', 'lognormal')
For more explanation, understanding, and figures, see the working paper, which illustrates all of powerlaw's features. For details of the math, see Clauset et al. 2007, which developed these methods.
Working paper illustrating all of powerlaw's features, with figures
Code examples from manuscript, as an IPython Notebook
Update Notifications, Mailing List, and Contacts
Note! This code works on Python 2.x, not 3.x. This code was developed and tested with the Enthought Python Distribution, and will update to 3.x whenever Enthought updates to 3.x. The full version of Enthought is available for free for academic use.
Many thanks to Andreas Klaus, Mika Rubinov and Shan Yu for helpful discussions. Thanks also to Andreas Klaus, Aaron Clauset, Cosma Shalizi, and Adam Ginsburg for making their code available. Their implementations were a critical starting point for making powerlaw.