Skip to main content

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: pypi.python.org/pypi/powerlaw.

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.

Acknowledgements

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.

Release history Release notifications | RSS feed

2.0.0

2 files

1.5

1 file

1.4.6

1 file

1.4.5

2 files

1.4.4

1 file

1.4.3

1 file

1.4.1

2 files

1.4

3 files

1.3.5

2 files

1.3.4

2 files

1.3.3

1.3.2

2 files

1.3.1

2 files

1.3

2 files

1.2.1

2 files

1.2

2 files

1.1.1

2 files

1.1

2 files

1.0

2 files

This release

0.8.3 This release

0.8.2

0.8.1

0.8

0.4.2

0.4.1

0.4

0.3.1

0.3

0.2

0.1

.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page