Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Estimate exponential cutoff in a power law distribution

As I have been doing some social network analysis, I have stumbled upon the problem of fitting a probability distribution on network degree.

So, I have a probability distribution P(X >= x) which, from visual inspection, follows a power law with an exponential cutoff rather than a pure power law (a straight line).

So, given that the equation for power law distribution with exponential cutoff is:

f(x) = x**alpha * exp(beta*x)

How might I estimate the parameters alpha and beta using Python?

I know scipy.stats.powerlaw package exists and they have a .fit() function but that doesn't seem to do the job as it only returns the location and scale of the plot, which seems to be useful only for normal distribution? There are also not enough tutorials on this package.

P.S. I'm well aware of the implementation of CLauset et al but they don't seem to provide ways to estimate the parameters of alternate distributions.

like image 586
Mike Avatar asked Jan 30 '12 11:01

Mike


People also ask

What is exponential cutoff?

(c) Power law with an exponential cutoff behaves like a power law for small values of x, but drops more steeply (exponentially) for larger x. (d) Log-normal/power law composite has a log-normal distribution (which can have a peak) for smaller x, and a power law for larger x.

Is power law same as exponential?

The essential difference is that an exponential function has its variable in its exponent, but a power function has its variable in its base. For example, f(x)=3x is an exponential function, but g(x)=x3 is a power function.


2 Answers

Powerlaw library can directly be used to estimate the parameters as follows:

  1. Install all the pythons dependencies:

    pip install powerlaw mpmath scipy
    
  2. Run the powerlaw package fit in a python environment:

    import powerlaw
    data = [5, 4, ... ]
    results = powerlaw.Fit(data)
    
  3. get the parameters from the results

    results.truncated_power_law.parameter1 # power law  parameter (alpha)
    results.truncated_power_law.parameter2 # exponential cut-off parameter (beta)
    
like image 185
atfornes Avatar answered Sep 18 '22 18:09

atfornes


The function scipy.stats.powerlaw.fit may still work for your purposes. It's a bit confusing how the distributions in scipy.stats work (the documentation for each one refers to the optional parameters loc and scale, even though not all of them use these parameters, and each uses them differently). If you look at the docs:

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.powerlaw.html

there's also a second non-optional parameter "a", which is the "shape parameters". In the case of powerlaw, this contains a single parameter. Don't worry about "loc" and "scale".

Edit: Sorry, forgot that you wanted the beta parameter too. Your best best may be to define the powerlaw function you want yourself, and then use scipy's generic fitting algorithms to learn the parameters. For example: http://www.scipy.org/Cookbook/FittingData#head-5eba0779a34c07f5a596bbcf99dbc7886eac18e5

like image 25
jamalex Avatar answered Sep 21 '22 18:09

jamalex