Solution (source code)

= Solution

The <Rao-Blackwell theorem> says that an unbiased finite-variance <estimator> $\delta(X)$ of a parameter function $\tau(\theta)$ can be improved using a <sufficient statistic> $T$. Define
$$
\delta^*(T)=\mathbb E[\delta(X)\mid T].
$$
Because the conditional <distribution> given $T$ is parameter-independent, this is a statistic computable without knowing $\theta$. The <tower property of conditional expectation> gives $\mathbb E_\theta\delta^*=\mathbb E_\theta\delta=\tau(\theta)$, so it remains unbiased. The <law of total variance> gives
$$
\operatorname{Var}_\theta(\delta)=\operatorname{Var}_\theta(\delta^*)+\mathbb E_\theta[\operatorname{Var}_\theta(\delta\mid T)].
$$
Hence \b[the improved estimator has no larger variance or mean squared error]:
$$
\boxed{\operatorname{Var}_\theta(\delta^*)\leq\operatorname{Var}_\theta(\delta),\qquad \mathbb E_\theta[(\delta^*-\tau(\theta))^2]\leq\mathbb E_\theta[(\delta-\tau(\theta))^2].}
$$
Equality holds precisely when $\delta=\delta^*(T)$ almost surely under the relevant parameter. More generally, even without unbiasedness, <conditional Jensen inequality> shows that conditioning on a sufficient statistic cannot increase risk for any convex loss in the estimate, provided the expectations exist. The squared-loss result above is the usual variance form of the theorem.