1 | initial version |
I used the hist() function from Matplotlib also, but does it allow to store the distribution in the list for? The problem is that I need to do some fitting to this distribution, and not only to visualize it.
I have found a way to achieve approximately what I need using the histogram() function from scipy.stats module.
Something like this:
from scipy.stats import histogram
distribution_list = histogram(data_list, numbins=10, defaultlimits=(90,164))
It gives the values for the bins, the first bin start and the bin width. To obtain the distribution list with the actual values for further work (like fitting, plotting, adding to something, etc.) one can do something like this:
from scipy.stats import histogram
distribution_list = histogram(data_list, numbins=10, defaultlimits=(90,164))
actual_distribution = []
i = 0
for bin in distribution_list[0]:
actual_distribution.append((distribution_list[1]+i*distribution_list[2], bin))
i+=1
But maybe there are some other (more simple or built-in or smarter) ways to get a distribution out of a list of numbers?
Thanks.