Search code examples
pythonnumpymatplotlibscipypower-law

powerlaw Python package errors


I'm currently trying to fit a set of (positive) data with the powerlaw.Fit() function from the powerlaw package. However, every single time I do this I obtain the following message:

<powerlaw.Fit at 0x25eac6d3e80>

which I've been trying to figure out what it means for ages, but obviously without success. Another issue that I've been facing is that whenever I plot my CCDF using

powerlaw.plot_ccdf()

and my PDF using

powerlaw.plot_pdf()

with my data, I only obtain a plot for the CCDF but nothing for the PDF. Why are all of these things happening? My data is within a NumPy array and looks as follows:

array([  9.90857053e-06,   3.45336391e-05,   4.06757403e-05, ...,
     6.91411789e-02,   6.92511375e-02,   7.45046008e-02])

I doubt there is any kind of issue with my data, since, as I said, I get the plot for the CCDF more than fine. Any kind of help would be highly appreciated. Thanks in advance. (Edit: the data is composed of 1908 non-integer values)


Solution

  • It probably helps to read the documentation. http://pythonhosted.org/powerlaw/

    powerlaw.Fit is a class, so when you call powerlaw.Fit(...), you will get an object with associated methods. Save the object in a variable, then pull the results you want from it. For example:

    results = powerlaw.Fit(data)
    print(results.find_xmin())
    

    The 'message' you are getting is just a placeholder for the Fit object that is created.