0

I need some basic help with the powerlaw package (https://pypi.python.org/pypi/powerlaw).

I have a list of data samples. When I use powerlaw.plot_pdf(data), I get a graph (* sorry, can't upload the graphs here as I dont have enough reputation yet).

However, when trying to create the same graph on my own (with this code):

ax.plot(data)
ax.set_yscale('log')
ax.set_xscale('log') 

I get a different graph.

Why is it? Maybe I should normalize the data first (if yes - how)? Or do I miss something more crucial? (If I get it right, using the powerlaw.plot_pdf(data) means ploting the data before fitting).

Another option would be to get the values of both the x and y axes that produce the graph of powerlaw.plot_pdf(data) somehow, but did not succeed with that either.

Thanks for your kind help,

Alon

Baba
  • 161
  • 1

1 Answers1

0

Solved.

After downloading the powerlaw code (https://code.google.com/p/powerlaw/source/checkout), things become clearer.

To get the values of both the x and y axes that produce the graph of powerlaw.plot_pdf(data):

edges, hist = powerlaw.pdf(data)

Now, instead of just plotting the data on a log log axes as described in the question, we should first produce the centers of the bins. These centers will be the values on the x axis. hist contain the values of the y axis:

 bin_centers = (edges[1:]+edges[:-1])/2.0

Now plot on a loglog axes:

plt.loglog(bin_centers, hist)
Baba
  • 161
  • 1