A histogram with m bins of width h puts height p̂j/h on bin j. Too many bins give a noisy estimate, too few a blurred one. The leave-one-out score needs no refitting: Ĵ(h) = 2/((n − 1)h) − (n + 1)/((n − 1)h) Σ p̂j2. The band of Theorem 6.20 works on the square-root scale, where every bin has the same standard deviation, and splits the error rate α over the m bins (Bonferroni): it covers the binned density f̄ = Ef̂, not f itself.
Bins of equal width on [0, 0.2] (galaxies, n = 1266), [−3, 3] (Bart Simpson, n = 1000; the few points outside go into the end bins) and [−7, 16] (glass refractive index, n = 214). Band: c = zα/(2m)/(2√(nh)), lower (max(√f̂ − c, 0))2, upper (√f̂ + c)2. The simulation draws new samples from the Bart Simpson density with a fixed seed and counts how often the band contains f̄ in every bin.
code/ch06_density_estimation.py (hist_J, hist_band, hist_band_coverage).