For a kernel density estimate f^(x)=1nh∑iK ⁣(x−xih) in one dimension, derive the leading terms of its bias and variance at a point x. Hence what is the bandwidth that minimises the asymptotic mean squared error, and at what rate does the error shrink with n?

Supervised learning, Parzen windows and kernel density estimation
Level L4 Advanced. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can use a Taylor expansion for the bias and see the bias–variance trade-off that fixes h∝n−1/5.

Key idea

bias≈h22κ2f′′(x) and var≈f(x)R(K)nh, so AMSE is minimised at h∝n−1/5 and decays as n−4/5.

Steps

  1. Assume K is a symmetric density with κ2=∫u2K(u) du and R(K)=∫K(u)2 du. The xi are i.i.d. with density f.
  2. Mean: Ef^(x)=1h∫K ⁣(x−th)f(t) dt=∫K(u)f(x−hu) du (substituting t=x−hu).
  3. Taylor expand f(x−hu)=f(x)−huf′(x)+12h2u2f′′(x)+…. The middle term vanishes by symmetry, so the bias is h22κ2f′′(x)+o(h2).
  4. Variance: f^ is an average of n independent terms, so Varf^(x)=1nVar[1hK ⁣(x−xih)]≈1nh2⋅h f(x)R(K)=f(x)R(K)nh.
  5. Add: AMSE(h)=h44κ22f′′(x)2+f(x)R(K)nh. The first term grows with h, the second shrinks.
  6. Differentiate and set to zero: h3κ22f′′2=fR(K)nh2, so hopt=(f(x)R(K)n κ22f′′(x)2)1/5∝n−1/5.
  7. At this h both terms are of order n−4/5, so AMSE ∝n−4/5. This is slower than the parametric rate n−1: this is the price of not assuming a model.
  8. Example: for a N(0,1) density at x=0 with a Gaussian kernel (κ2=1, R=1/(2π)=0.282, f=0.399, f′′=−0.399) and n=1000, hopt=(0.282/(1000×0.399))1/5≈0.234.

Common mistakes

How long your answer should be

One page; 10 minutes.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: Why is gradient boosting called gradient descent in function space, what are the pseudo-residuals for squared, absolute and logistic loss, and what is the full algorithm with regression trees as base learners?
Next in Supervised learning: Show that, as n→∞, the error rate of the 1-nearest-neighbour classifier for two classes is at most 2R∗(1−R∗), where R∗ is the Bayes error. What does it say numerically for R∗=0.1?