Histograms III: MISE and the optimal binwidth
This post belongs to a series of study notes I first published in 2011, at the start of my PhD. I revised it in 2026: the mathematics was checked and corrected and the text rewritten.
First, the question from the last post: is \(\hat f_h(x)\) consistent? Yes. If \(h \to 0\) and \(nh \to \infty\), the MSE tends to zero, so \(\hat f_h(x)\) converges to \(f(x)\) in mean square. Convergence in mean square implies convergence in probability (by Chebyshev’s inequality), hence \(\hat f_h(x) \xrightarrow{P} f(x)\).
From MSE to MISE
The pointwise MSE we derived,
\[ \operatorname{MSE}\big(\hat f_h(x)\big) = \frac{f(x)}{nh} + f'(x)^2\Big(\big(j - \tfrac12\big)h - x\Big)^2 + o(h^2) + o\!\left( \frac{1}{nh} \right), \qquad x \in B_j, \tag{1}\]
depends on the unknown \(f\) at each point. A single global measure of accuracy is more useful for choosing \(h\). The most common is the mean integrated squared error (MISE):
\[ \operatorname{MISE}(\hat f_h) = \mathbb{E}\int_{-\infty}^{\infty} \big(\hat f_h(x) - f(x)\big)^2 dx = \int_{-\infty}^{\infty} \operatorname{MSE}\big(\hat f_h(x)\big)\, dx, \]
where exchanging expectation and integral is justified by Tonelli’s theorem, since the integrand is non-negative.
We integrate the two leading terms of Equation 1 separately.
Integrated variance. Since \(f\) integrates to one,
\[ \int \frac{f(x)}{nh}\, dx = \frac{1}{nh}. \]
Integrated squared bias. Write \(m_j = (j - \tfrac12)h\) for the midpoint of \(B_j\). On each bin, \(f'(x)^2 \approx f'(m_j)^2\), and \(\int_{B_j} (m_j - x)^2 dx = \int_{-h/2}^{h/2} t^2 dt = h^3/12\). Hence
\[ \sum_{j} \int_{B_j} f'(x)^2 (m_j - x)^2\, dx \approx \sum_j f'(m_j)^2\, \frac{h^3}{12} = \frac{h^2}{12} \sum_j h\, f'(m_j)^2 \approx \frac{h^2}{12} \int f'(x)^2\, dx, \]
where the last step recognizes a Riemann sum. Writing \(\|f'\|_2^2 = \int f'(x)^2 dx\) for the squared \(L_2\) norm of \(f'\),
\[ \operatorname{MISE}(\hat f_h) = \frac{1}{nh} + \frac{h^2}{12} \|f'\|_2^2 + o\!\left( \frac{1}{nh} \right) + o(h^2), \qquad h \to 0,\; nh \to \infty. \]
Dropping the remainder terms gives the asymptotic MISE:
\[ \operatorname{AMISE}(\hat f_h) = \frac{1}{nh} + \frac{h^2}{12} \|f'\|_2^2 . \]
Optimal binwidth
Setting the derivative of the AMISE with respect to \(h\) to zero,
\[ \frac{\partial \operatorname{AMISE}(\hat f_h)}{\partial h} = -\frac{1}{nh^2} + \frac{h}{6} \|f'\|_2^2 = 0 \quad \Longrightarrow \quad h_{\text{opt}} = \left( \frac{6}{n \|f'\|_2^2} \right)^{1/3} \propto n^{-1/3}. \]
At \(h_{\text{opt}}\) the squared-bias term equals half the variance term, and
\[ \operatorname{AMISE}(h_{\text{opt}}) = \frac{3}{2\, n\, h_{\text{opt}}} \propto n^{-2/3}. \]
The histogram’s error therefore decreases at rate \(n^{-2/3}\), slower than the \(n^{-1}\) rate of a correctly specified parametric model. That is the price of not assuming a parametric form.
There is still a practical problem: \(h_{\text{opt}}\) depends on \(\|f'\|_2^2\), which is unknown because \(f\) is unknown.
Question for you: what is \(h_{\text{opt}}\) exactly when \(f\) is the standard normal density, \(f(x) = \frac{1}{\sqrt{2\pi}} e^{-x^2/2}\)?
The next post answers it and checks the theory with a simulation.
References
Further reading: Härdle et al. (2004, chap. 2); Scott (1979).
Series: Density estimation · Previous: Histograms II · Next: Histograms IV