Solution (source code)

= Solution
{c}

The <Neyman-Pearson lemma> concerns a <simple hypothesis> $H_0:\theta=\theta_0$ against another <simple hypothesis> $H_1:\theta=\theta_1$. For a continuous <statistical sample>, put $f_j(x)=\prod_i f(x_i;\theta_j)$ for the joint <probability density functions>, $j=0,1$. A <randomized statistical test> is a measurable $\phi(x)\in[0,1]$, the conditional <probability> of rejection after observing $x$. Its <test size> is $\mathbb E_0\phi$ and its <statistical power> is $\mathbb E_1\phi$.

Choose $k\geq0$ and boundary randomization so that
$$
\phi_*(x)=\begin{cases}
1,&f_1(x)>kf_0(x),\\
0,&f_1(x)<kf_0(x),\\
\gamma(x)\in[0,1],&f_1(x)=kf_0(x),
\end{cases}
\qquad\mathbb E_0\phi_* =\alpha.
$$
Then \b[$\phi_*$ is most powerful among all tests of size at most $\alpha$]. Thus one rejects for sufficiently large alternative-to-null <likelihood ratio>. If the equality set has zero <probability> under $H_0$, the test needs no randomization. Continuous observations alone do not guarantee that their <likelihood ratio> has a continuous <probability distribution>.

For the proof, let $\phi$ be any competing test with $\mathbb E_0\phi\leq\alpha$. At every $x$,
$$
(\phi_*(x)-\phi(x))(f_1(x)-kf_0(x))\geq0.
$$
Indeed, on $f_1>kf_0$ the first factor is $1-\phi\geq0$; on $f_1<kf_0$ it is $-\phi\leq0$; and on equality the product is zero. <Integration> gives
$$
\mathbb E_1\phi_* -\mathbb E_1\phi
\geq k(\mathbb E_0\phi_* -\mathbb E_0\phi)\geq0,
$$
which proves the claimed optimality. Moreover, when $k>0$, equality of <statistical power> forces equality of <test size> and forces $\phi=\phi_*$ almost everywhere where $f_1\ne kf_0$: otherwise the nonnegative integrand would have positive <integral>. This proves the usual necessity assertion as well, up to equality sets and sets of zero <probability> under both hypotheses.