Data are N draws from N(θ*, 1) and the loss is squared error, so the risk of an estimator is its mean squared error as a function of the unknown θ*. No estimator is best for every θ*: the constant θ0 wins at θ* = θ0 and is terrible elsewhere, the posterior means win near θ0, and the sample mean has the smallest worst case. The right panel shows that in dimension d ≥ 3 the sample mean is even dominated everywhere by the James-Stein estimator.
Risks of the mean, the constant and the posterior means are exact formulas; the median's risk is the exact variance of the median of N standard normals (a table computed by numerical integration of the order-statistic density). The dots are Monte Carlo estimates from a seeded generator, a check that risk really is an average over data sets. In the right panel the James-Stein risk is d − (d−2)2 E[1/||X||2] with a Poisson mixture for the non-central chi-square.
code/ch05_decision_theory.py (risk_postmean, median_var_exact, js_risk, bayes_risk_postmean).