I got one question about the numpy.histogram option normed, the function is:
numpy.histogram(a, bins=10, range=None, normed=False, weights=None, density=None)
By the definition: numpy.histogram
normed : bool, optional
This keyword is deprecated in Numpy 1.6 due to confusing/buggy behavior. It will be removed in Numpy 2.0. Use the density keyword instead. If False, the result will contain the number of samples in each bin. If True, the result is the value of the probability density function at the bin, normalized such that the integral over the range is 1. Note that this latter behavior is known to be buggy with unequal bin widths; use density instead. weights : array_like, optional
I try it with this code:
imhist, bins = histogram([0,1,2,3], bins=4, normed=True)
print "normed=True:", imhist
print "bins:", bins
Output:
normal=True: [ 0.33333333 0.33333333 0.33333333 0.33333333]
bins: [ 0. 0.75 1.5 2.25 3. ]
imhist, bins = histogram([0,1,2,3], bins=4)
print "normed=None:", imhist
print "bins:", bins
Output:
normal=None: [1 1 1 1]
bins: [ 0. 0.75 1.5 2.25 3. ]
What I am feel confused is about the when normed=True, "the result is the value of the probability density function at the bin, normalized such that the integral over the range is 1." Because I thought the imhist should be this:
normal=True: [0.25 0.25 0.25 0.25]
The 4 values equally drop in 4 bins, and that is why "normal=None: [1 1 1 1]"
Value:[ 0 1 2 3 ]
bins: [ 0. 0.75 1.5 2.25 3. ]
I have refer to this How does numpy.histogram() work? post, but it does use the normed=True option.