Freedman-Diaconis rule

In statistics, the Freedman-Diaconis rule can be used to select the size of the bins to be used in a histogram. The general equation for the rule is:


 * $$\mbox{Bin size}=2\, \mbox{IQR}(x) n^{-1/3} \;$$

where


 * $$\scriptstyle\operatorname{IQR}(x) \;$$ is the interquartile range of the data
 * $$\scriptstyle n \;$$ is the number of observations in the sample $$\scriptstyle x. \; $$

Sturges' rule
Another approach is the use Sturges' rule: use a bin so large that there are about $$\scriptstyle 1+\log_2n$$ non-empty bins.

Reference

 * David Freedman and Persi Diaconis (1981). "On the histogram as a density estimator: L2 theory." Probability Theory and Related Fields. 57(4): 453-476