Science Score: 20.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
    3 of 20 committers (15.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.9%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: jeffalstott
  • Language: Jupyter Notebook
  • Default Branch: master
  • Homepage:
  • Size: 3.94 MB
Statistics
  • Stars: 623
  • Watchers: 34
  • Forks: 133
  • Open Issues: 29
  • Releases: 0
Created over 14 years ago · Last pushed about 1 year ago
Metadata Files
Readme

README.rst

powerlaw: A Python Package for Analysis of Heavy-Tailed Distributions
=====================================================================

``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. (2014). powerlaw: a Python package
for analysis of heavy-tailed distributions. `PLoS ONE 9(1): e85777 `_

Also available at `arXiv:1305.0215 [physics.data-an] `_


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 paper,
which illustrates all of ``powerlaw``'s features. For details of the math, 
see Clauset et al. 2007, which developed these methods.

Quick Links
------------
`Paper illustrating all of powerlaw's features, with figures `__

`Code examples from manuscript, as an IPython Notebook `__
Note: Some results involving lognormals will now be different from the
manuscript, as the lognormal fitting has been improved to allow for
greater numerical precision.

`Documentation `__

This code was developed and tested for Python 2.x with the 
`Enthought Python Distribution `__,  and later amended to be
compatible with 3.x. The full version of Enthought is 
`available for free for academic use `__.


Installation
------------
``powerlaw`` is hosted on `PyPI `__, so installation is straightforward. The easiest way to install type this at the command line (Linux, Mac, or Windows)::

    easy_install powerlaw

or, better yet::

    pip install powerlaw

``easy_install`` or ``pip`` just need to be on your PATH, which for Linux or Mac is probably the case.

``pip`` should install all dependencies automagically. These other dependencies are ``numpy``, ``scipy``, and ``matplotlib``. These are all present in Enthought, Anaconda, and most other scientific Python stacks. To fit truncated power laws or gamma distributions, ``mpmath`` is also required, which is less common and is installable with::

    pip install mpmath

The requirement of ``mpmath`` will be dropped if/when the ``scipy`` functions ``gamma``, ``gammainc`` and ``gammaincc`` are updated to have sufficient numerical accuracy for negative numbers.

You can also build from source from the code here on Github, though it may be a development version slightly ahead of the PyPI version.


Update Notifications and Mailing List
-----------------
Get notified of updates by joining the Google Group `here `__.

Questions/discussions/help go on the Google Group `here `__. Also receives update info.

Further Development
-----------------
The original author of `powerlaw`, Jeff Alstott, is now only writing minor tweaks, but ``powerlaw`` remains open for further development by the community. If there's a feature you'd like to see in ``powerlaw`` you can `submit an issue `_, but pull requests are even better. Offers for expansion or inclusion in other projects are welcomed and encouraged.


Acknowledgements
-----------------
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``.


Power Laws vs. Lognormals and powerlaw's 'lognormal_positive' option
-----------------
When fitting a power law to a data set, one should compare the goodness of fit to that of a `lognormal distribution `__. This is done because lognormal distributions are another heavy-tailed distribution, but they can be generated by a very simple process: multiplying random positive variables together. The lognormal is thus much like the normal distribution, which can be created by adding random variables together; in fact, the log of a lognormal distribution is a normal distribution (hence the name), and the exponential of a normal distribution is the lognormal (which maybe would be better called an expnormal). In contrast, creating a power law generally requires fancy or exotic generative mechanisms (this is probably why you're looking for a power law to begin with; they're sexy). So, even though the power law has only one parameter (``alpha``: the slope) and the lognormal has two (``mu``: the mean of the random variables in the underlying normal and ``sigma``: the standard deviation of the underlying normal distribution), we typically consider the lognormal to be a simpler explanation for observed data, as long as the distribution fits the data just as well. For most data sets, a power law is actually a worse fit than a lognormal distribution, or perhaps equally good, but rarely better. This fact was one of the central empirical results of the paper `Clauset et al. 2007 `__, which developed the statistical methods that ``powerlaw`` implements. 

However, for many data sets, the superior lognormal fit is only possible if one allows the fitted parameter ``mu`` to go negative. Whether or not this is sensible depends on your theory of what's generating the data. If the data is thought to be generated by multiplying random positive variables, ``mu`` is just the log of the distribution's median; a negative ``mu`` just indicates those variables' products are typically below 1. However, if the data is thought to be generated by exponentiating a normal distribution, then ``mu`` is interpreted as the median of the underlying normal data. In that case, the normal data is likely generated by summing random variables (positive and negative), and ``mu`` is those sums' median (and mean). A negative ``mu``, then, indicates that the random variables are typically negative. For some physical systems, this is perfectly possible. For the data you're studying, though, it may be a weird assumption. For starters, all of the data points you're fitting to are positive by definition, since power laws must have positive values (indeed, ``powerlaw`` throws out 0s or negative values). Why would those data be generated by a process that sums and exponentiates *negative* variables?

If you think that your physical system could be modeled by summing and exponentiating random variables, but you think that those random variables should be positive, one possible hacks is ``powerlaw``'s ``lognormal_positive``. This is just a regular lognormal distribution, except ``mu`` must be positive. Note that this does not force the underlying normal distribution to be the sum of only positive variables; it only forces the sums' *average* to be positive, but it's a start. You can compare a power law to this distribution in the normal way shown above::

    R, p = results.distribution_compare('power_law', 'lognormal_positive')
    
You may find that a lognormal where ``mu`` must be positive gives a much worse fit to your data, and that leaves the power law looking like the best explanation of the data. Before concluding that the data is in fact power law distributed, consider carefully whether a more likely explanation is that the data was generated by multiplying positive random variables, or even by summing and exponentiating random variables; either one would allow for a lognormal with an intelligible negative value of ``mu``.

Owner

  • Name: Jeff Alstott
  • Login: jeffalstott
  • Kind: user

GitHub Events

Total
  • Issues event: 3
  • Watch event: 23
  • Issue comment event: 3
  • Push event: 1
  • Pull request review event: 2
  • Pull request event: 2
  • Fork event: 2
Last Year
  • Issues event: 3
  • Watch event: 23
  • Issue comment event: 3
  • Push event: 1
  • Pull request review event: 2
  • Pull request event: 2
  • Fork event: 2

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 359
  • Total Committers: 20
  • Avg Commits per committer: 17.95
  • Development Distribution Score (DDS): 0.123
Past Year
  • Commits: 4
  • Committers: 3
  • Avg Commits per committer: 1.333
  • Development Distribution Score (DDS): 0.5
Top Committers
Name Email Commits
Jeff Alstott j****t@g****m 315
jeff j****f@j****l 9
Larry Eisenman l****n@h****m 6
Emre Safak m****e@y****m 5
Adam Ginsburg (keflavich) k****h@g****m 4
A.Capelli C****s@u****m 3
Christopher Strickland m****t@g****m 2
Henry Martin m****e@e****h 2
Mikki Fudolig m****e@g****m 2
Andreas Bilke a****s@b****g 1
Chris Down c****s@c****e 1
David R. Bild d****d@u****u 1
Denis Kataev b****o@g****m 1
Haochen Wu w****2@g****m 1
Philipp Fischbeck p****k@h****e 1
sx349 s****9@u****m 1
RiptideBo 2****5@q****m 1
Harvey Stein h****n@t****m 1
Larry Eisenman L****n@w****u 1
nsfzyzz y****1@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 77
  • Total pull requests: 26
  • Average time to close issues: 6 months
  • Average time to close pull requests: 22 days
  • Total issue authors: 63
  • Total pull request authors: 18
  • Average comments per issue: 3.04
  • Average comments per pull request: 1.92
  • Merged pull requests: 24
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • jeffalstott (5)
  • henrymartin1 (3)
  • anntzer (2)
  • ghost (2)
  • mountaindust (2)
  • bostockm (2)
  • mdf-github (2)
  • charlesmartin14 (2)
  • BMo-design (2)
  • sx349 (2)
  • PabloLeon (1)
  • karandeep8 (1)
  • lo-hfk (1)
  • smartass101 (1)
  • psinger (1)
Pull Request Authors
  • lneisenman (5)
  • Cils (2)
  • jeffalstott (2)
  • drbild (2)
  • henrymartin1 (2)
  • wuhaochen (1)
  • esafak (1)
  • sx349 (1)
  • mdf-github (1)
  • cdown (1)
  • nsfzyzz (1)
  • keflavich (1)
  • RiptideBo (1)
  • mountaindust (1)
  • kataev (1)
Top Labels
Issue Labels
Feature Request (5)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 55,049 last-month
  • Total docker downloads: 610
  • Total dependent packages: 19
    (may contain duplicates)
  • Total dependent repositories: 116
    (may contain duplicates)
  • Total versions: 32
  • Total maintainers: 3
pypi.org: powerlaw

Toolbox for testing if a probability distribution fits a power law

  • Versions: 30
  • Dependent Packages: 15
  • Dependent Repositories: 112
  • Downloads: 55,049 Last month
  • Docker Downloads: 610
Rankings
Dependent packages count: 0.7%
Downloads: 1.0%
Dependent repos count: 1.4%
Docker downloads count: 1.9%
Average: 2.0%
Stargazers count: 2.7%
Forks count: 4.2%
Maintainers (3)
Last synced: 10 months ago
conda-forge.org: powerlaw
  • Versions: 1
  • Dependent Packages: 3
  • Dependent Repositories: 2
Rankings
Dependent packages count: 15.6%
Forks count: 16.3%
Stargazers count: 17.2%
Average: 17.3%
Dependent repos count: 20.2%
Last synced: 11 months ago
anaconda.org: powerlaw

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.

  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 2
Rankings
Forks count: 28.3%
Stargazers count: 29.1%
Dependent packages count: 30.7%
Average: 34.2%
Dependent repos count: 48.7%
Last synced: 11 months ago

Dependencies

setup.py pypi
  • matplotlib *
  • mpmath *
  • numpy *
  • scipy *