I don't understand the output of numpy's histogram function when density is True. When I do this:
hist = np.histogram(np.array([1,1, 2,3,4]), 4, density = False)
print("histogram: ", hist)
output is:
histogram: (array([2, 1, 1, 1]), array([1. , 1.75, 2.5 , 3.25, 4. ]))
It is clear to me. I crated 4 intervals array([1. , 1.75, 2.5 , 3.25, 4. ]) and array([2, 1, 1, 1] are numbers of elements in each interval. But when I do it with density = True:
hist = np.histogram(np.array([1,1, 2,3,4]), 4, density = True)
print("histogram: ", hist)
result is:
histogram: (array([0.53333333, 0.26666667, 0.26666667, 0.26666667]), array([1. , 1.75, 2.5 , 3.25, 4. ]))
I dint understand what are those numbers array([0.53333333, 0.26666667, 0.26666667, 0.26666667]). Documentation says that it is probability density function, but sum of PDF use be 1, so its not percentage of each element type. My question is, how those numbers are calculated? Could you explain on my given example?