pylab.hist(data, normed=1). Normalization seems to work incorrect


I'm trying to create a histogram with argument normed=1

For instance:

import pylab

data = ([1,1,2,3,3,3,3,3,4,5.1])    
pylab.hist(data, normed=1)

I expected that the sum of the bins would be 1. But instead, one of the bin is bigger then 1. What this normalization did? And how to create a histogram with such normalization that the integral of the histogram would be equal 1?

enter image description here

3/31/2011 12:51:37 PM

See my other post for how to make the sum of all bins in a histogram equal to one:

Copy & Paste:

weights = np.ones_like(myarray)/float(len(myarray))
plt.hist(myarray, weights=weights)

where myarray contains your data

5/23/2017 12:17:54 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow