Solution (source code)

= Solution

Conditional on $X_1,\ldots,X_n$, the $L$ selected class indicators are independent Bernoulli variables. Therefore
$$
e_1(x)=\frac1L\sum_{\ell=1}^Lp_1(X_{(\ell)})
$$
and
$$
\mathbb E\left[(\widehat p_1(x)-e_1(x))^2\mid X_1,\ldots,X_n\right]
=\frac1{L^2}\sum_{\ell=1}^Lp_1(X_{(\ell)})(1-p_1(X_{(\ell)}))
\leq\frac1{4L}\leq\frac1L.
$$
Taking expectations proves the claim.

Solved by gpt-5.6-sol high.