Search code examples
pythonpower-law

Fitting a power-law with powerlaw.py in Python 3


I am trying to fit power law with powerlaw.py:

data = [1.7, 3.2, 4.3, 2.1, 0.9, 3.3, 1.2, 4.3]
fit = powerlaw.Fit(data)

I'm getting the warning:

IndexError: 0-d arrays can only use a single () or a list of newaxes
(and a single ...) as an index

I've tested also data which were used in these code examples and I have always the same problem.

Why this happens?


Solution

  • I just ran code:

    In [1]: import powerlaw

    In [2]: data = [1.7, 3.2, 4.3, 2.1, 0.9, 3.3, 1.2, 4.3]

    In [3]: fit = powerlaw.Fit(data) Calculating best minimal value for power law fit /usr/lib/python2.7/site-packages/powerlaw-1.3-py2.7.egg/powerlaw.py:686: RuntimeWarning: invalid value encountered in divide (Theoretical_CDF * (1 - Theoretical_CDF))

    In [4]: fit.sigma Out[4]: 0.37880479849893711

    might want to check for a bug elsewhere... if not might be a version error