Freedman–Diaconis rule

In statistics, the Freedman–Diaconis rule can be used to select the width of the bins to be used in a histogram. It is named after David A. Freedman and Persi Diaconis.

For a set of empirical measurements sampled from some probability distribution, the Freedman–Diaconis rule is designed approximately minimize the integral of the squared difference between the histogram (i.e., relative frequency density) and the density of the theoretical probability distribution.

In detail, the Integrated Mean Squared Error (IMSE) is

\text{IMSE} = E\left[ \int_I (H(x) - f(x))^2 \right] $$ where $$H$$ is the histogram approximation of $$f$$ on the interval $$I$$ computed with $$n$$ data points sampled from the distribution $$f$$. $$E[\cdot]$$ denotes the expectation across many independent draws of $$n$$ data points. Under mild conditions, namely that $$f$$ and its first two derivatives are $L^2$, Freedman and Diaconis show that the integral is minimised by choosing the bin width



h^* = \left( 6 / \int_{-\infty}^{\infty} f'(x)^2 dx \right)^{1/3}n^{-1/3} $$

A formula which was derived earlier by Scott. Swapping the order of the integration and expectation is justified by Fubini's Theorem. The Freedman–Diaconis rule is derived by assuming that $$f$$ is a Normal distribution, making it an example of a normal reference rule. In this case $$\int f'(x)^2 = (4 \sqrt{\pi} \sigma^3)^{-1}$$.

Freedman and Diaconis use the interquartile range to estimate the standard deviation: $$\sigma \sim \phi^{-1}(0.75) - \phi^{-1}(0.25)$$ where $$\Phi$$ is the cumulative distribution function for a normal density. This gives the rule


 * $$\text{Bin width}=2\, { \text{IQR}(x) \over{ \sqrt[3]{n}  }}$$

where $$\operatorname{IQR}(x) $$ is the interquartile range of the data and $$ n $$ is the number of observations in the sample $$ x $$. In fact if the normal density is used the factor 2 in front comes out to be $$\sim 2.59$$, but 2 is the factor recommended by Freedman and Diaconis.

Other approaches


With the factor 2 replaced by approximately 2.59, the Freedman–Diaconis rule asymptotically matches Scott's Rule for data sampled from a normal distribution.

Another approach is to use Sturges's rule: use a bin width so that there are about $$ 1+\log_2n $$ non-empty bins, however this approach is not recommended when the number of data points is large. For a discussion of the many alternative approaches to bin selection, see Birgé and Rozenholc.