For a Normal mixture the risk of a histogram and of a Gaussian kernel estimate can be computed exactly, for any sample size and any width, without simulation. The top right panel splits each risk into integrated squared bias and integrated variance (the book's Figure 20.2, computed). Minimising over the width and letting n grow gives the top left panel: on log-log axes the optimal risks become straight lines of slopes −2/3 (histogram) and −4/5 (kernel), and the simulated errors (dots) follow them. The bottom panel moves to d dimensions, where the kernel rate is n−4/(4+d): the curse of dimensionality.
Histogram bins of width h start at 0; the kernel is Gaussian with standard deviation h. Each optimal width is found by a grid search over log h followed by golden-section refinement. Each simulated dot is the average integrated squared error of the replicates at the exact optimal width (±2 Monte Carlo standard errors); the kernel error is computed on a grid of 2048 points. Replicate r at size n uses its own seeded generator. In d dimensions the true density is N(0, Id) and the kernel a product of Normals with a common width.
code/ch20_nonparametric_curve_estimation.py (hist_mise_exact, kde_mise_exact, opt_h, rate_sim, kde_mise_nd, silverman_n).