Skip to main content

Toolbox for testing if a probability distribution fits a power law

Project description

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. This package is in “open beta”, which means everything pretty much works but it’s being tweaked and expanded on. Academics, please cite as:

Jeff Alstott. (2012). powerlaw Python package. Web address:

Basic Usage

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.


Many thanks to Mika Rubinov and Shan Yu for helpful discussions and to Adam Ginsburg for posting his code, which inspired the xmin-selection function of this toolbox.

Project details

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page