Solution (source code)

= Solution
{c}

Let $S=\sum_iX_i$, which has a <binomial distribution> with parameters $(n,p)$. For $0<p_1<1/2$, the alternative-to-null <likelihood ratio> of the independent <Bernoulli trials> is
$$
R(S)=\frac{p_1^S(1-p_1)^{n-S}}{(1/2)^n}
=[2(1-p_1)]^n\left(\frac{p_1}{1-p_1}\right)^S.
$$
Since $p_1/(1-p_1)<1$, this is strictly decreasing in $S$. A threshold on large $R$ is therefore a lower-tail <likelihood-ratio test>, and a threshold between $R(2)$ and $R(1)$ gives the stated <critical region> $S<2$. The <Neyman-Pearson lemma> also proves it is a <most powerful test> at its attained <test size>.

Using the <binomial probability mass>, its <test size> and <statistical power> are respectively
$$
\boxed{\mathbb P_{1/2}(S<2)=\frac{1+n}{2^n}},\qquad
\boxed{\mathbb P_{p_1}(S<2)=(1-p_1)^n+np_1(1-p_1)^{n-1}}.
$$
The associated <power function> is $\pi(p)=(1-p)^n+np(1-p)^{n-1}$. These formulas hold for positive integer $n$; when $n=1$ the test always rejects and has size one. If the boundary value $p_1=0$ is admitted, all alternative <probability> is at $S=0$; the same test still has <statistical power> one and can be represented using a threshold with ties in the <likelihood ratio>.