Cómo ajustar powerlaw a un histograma con matplotlib

I am trying to fit a power law to a histogram (more exact Pareto distribution). I did it with my own function, where I check for smallest sum of squares of difference. But this means I need to loop threw all the coefitients, which can take some time. Another problem is that I need to make my own data list so that I have histogram data.

So I am looking for a function that would return a list of data made by matplotlib.pyplot.hist() and not just a picture and than I would like to fit this data with pareto distribution abit faster than looping so many times and obtain the coefitions.

preguntado el 08 de noviembre de 11 a las 12:11

1 Respuestas

I think you are looking for the values and the bin sizes.

La matplotlib.pyplot.hist() function returns a tupe with (n, bins, patches)

For more information about this function click this link

For example to plot some 'data', 150 bins:

import matplotlib.pyplot as plt
hist = plt.hist(data,150)
binsize = hist[0]
value = hist[1]
print binsize
print ''
print value

Respondido el 09 de diciembre de 11 a las 00:12

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.