# Most Powerful Test Among Two Distributions (Hypothesis Testing / Decision Rule)

Assume that $X$ is a discrete random variable. Based on an observed value of $X$, derive the most powerful test of $H_0:X\sim GEO(1-\lambda)$ vs $H_a: X\sim POI(\lambda)$ for a given value of $\alpha$, and find the power of this test.

If we take the ratio of the alternative distribution to the null, we'll find that:

$$\frac{f_a(x)}{f_0(x)}=\frac{e^{-\lambda}}{(1-\lambda)x!}$$

But in order to derive the randomized decision rule, I need to know the distribution of $X!$ under the null hypothesis. Clearly there's an issue with this, so I must be missing something. Surely something's wrong here, and if not, then I'm just completely lost.

So what is the decision rule for this most powerful test, and how can you derive it?

The randomized decision rule dictates accepting the alternative hypothesis necessarily if the likelihood ratio is greater than some constant $c$, and with some probability $p$ if this ratio is equal to this constant. And $C$ and $p$ are s.t. $$\alpha = \mathbb P_0\left(\frac{f_a(X)}{f_0(X)}>c\right)+p\mathbb P_0\left(\frac{f_a(X)}{f_0(X)}=c\right).$$ Consider the values of likelihood ratio for $X=0,1,2,\ldots$: $$\frac{f_a(0)}{f_0(0)}=\frac{f_a(1)}{f_0(1)}=\frac{e^{-\lambda}}{1-\lambda}, \ \frac{f_a(2)}{f_0(2)}=\frac{e^{-\lambda}}{2(1-\lambda)}, \ \frac{f_a(3)}{f_0(3)}=\frac{e^{-\lambda}}{6(1-\lambda)}, \ldots$$ The likelihood ratio can take only these values. So we do not need to take other values of $c$ than $c=\frac{e^{-\lambda}}{k!(1-\lambda)}$. Note also that the likelihood ratio is monotone function of $X$ for $X\geq 2$, and for $X=0$ and $1$ the values of l.r. are equal.
For any $k\geq 2$ $$\mathbb P_0\left(\frac{f_a(X)}{f_0(X)}>\frac{e^{-\lambda}}{k!(1-\lambda)}\right)=\mathbb P_0(X<k)=1-\lambda^k.$$ And if $\alpha\geq 1-\lambda^2$, then we can find $k\geq 2$ s.t. $$\mathbb P_0(X<k)\leq\alpha <\mathbb P_0(X\leq k).$$ Solve these inequalities and find that $k=\left\lfloor\frac{\ln(1-\alpha)}{\ln\lambda}\right\rfloor$ bounds the critical region from above. The randomization probability $p$ can be found as $$\alpha = \mathbb P_0(X<k)+p\mathbb P_0(X=k) = 1-\lambda^k+p(1-\lambda)\lambda^k, \quad p=\frac{\alpha-(1-\lambda^k)}{(1-\lambda)\lambda^k}.$$
The case $0<\alpha<1-\lambda^2$ corresponds to $c=\frac{e^{-\lambda}}{1-\lambda}$. The inequality $\frac{f_a(X)}{f_0(X)}>c$ is impossible now. And $$\frac{f_a(X)}{f_0(X)}=c \iff X=0 \vee 1,$$ $$\mathbb P_0\left(\frac{f_a(X)}{f_0(X)}=c\right)=\mathbb P_0(X=0)+\mathbb P_0(X=1)=1-\lambda^2.$$ So, this case the test reject null hypothesis with probability $$p = \frac{\alpha}{1-\lambda^2}$$
Finally, the UMP test with type-1 error $\alpha\geq 1-\lambda^2$ looks like $$\varphi(X)=\begin{cases}1, & X< k,\cr p, & X=k, \cr 0, & X> k, \end{cases} \ \text{ where } k=\left\lfloor\frac{\ln(1-\alpha)}{\ln\lambda}\right\rfloor, \ p=\frac{\alpha-(1-\lambda^k)}{(1-\lambda)\lambda^k}.$$
For $\alpha<1-\lambda^2$ UMP test looks like $$\varphi(X)=\begin{cases} p, & X=0 \text{ or } 1, \cr 0, & X\geq 2, \end{cases} \ \text{ where } p=\frac{\alpha}{1-\lambda^2} .$$