How to calculate peakiness or uniformity in histogram? I have a histogram with 20 bins ranging from -1 to 1 with an interval of 0.1.
I would like to know if the histogram distribution is uniform or is peaked.
I want to compare several such histograms and take the one which has more "uniform" distribution and less peaks.
Any suggestions on how to proceed ?
 A: The answer depends on what you are trying to do:


*

*Are you trying to infer which histogram was mostly likely to be generated by a uniform distribution OR

*Trying to find which histogram demonstrates the least non-uniformity?


These questions may seem the same, but they are not. Inference is very sensitive to the sample size, whereas descriptive measure take the data at face value.
If you are going for (1), then the suggestions in the comments or link will work fine. However, if you are trying to find the most uniform histogram, then this is not an inference problem, but a measurement problem...how do you measure non-uniformity?
At the risk of appearing shamelessly self-promoting, I recently answered a similar question by describing a method I developed to rand distributions by their degree of uniformity. Take a look and see if you think it is relevant to your problem.
A: One possible approach would be to use the Chi-square test to compare the "observed" histogram counts with the "expected" uniform distribution.
The chi-square test statistic or its p-value may be used as a possible metric of "(non)uniformness" - highly non-uniform histograms would tend to have high chi-square values and the corresponding p-values approaching zero.
In Python:
from scipy.stats import chisquare
uniformness = chisquare(counts_vector).pvalue

