# Are my calculations using Neymann Pearson lemma correct?

I read this post, but I need to use N-P lemma to verify hypothesis doing it really step by step, so please help me.

$X_1,X_2,\ldots,X_{30}\sim N(\mu, 1)$, so $\sigma=1$ (I assume that) and $n=30$.

$H_0:\mu_0 = 0$ against $H_1:\mu_1=1$

Likelihood functions first:

$L(\mu_0=0|x)=\frac{1}{\sqrt{2\pi}\cdot 1}\cdot exp\{\frac{-(x_1-0)^2}{2\cdot1^2}\}\cdot\frac{1}{\sqrt{2\pi}\cdot 1}\cdot exp\{\frac{-(x_2-0)^2}{2\cdot1^2}\}\cdots\frac{1}{\sqrt{2\pi}\cdot 1}\cdot exp\{\frac{-(x_{30}-0)^2}{2\cdot1^2}\}=(\frac{1}{\sqrt{2\cdot\pi}})^{30}\cdot exp\{-\frac{1}{2}\cdot\sum_{i=1}^{30}(x_i-0)^2\}= (\frac{1}{\sqrt{2\cdot\pi}})^{30}\cdot exp\{-\frac{1}{2}\cdot\sum_{i=1}^{30}x_i^2\}$

$L(\mu_1=1|x)=\frac{1}{\sqrt{2\pi}\cdot 1}\cdot exp\{\frac{-(x_1-1)^2}{2\cdot1^2}\}\cdot\frac{1}{\sqrt{2\pi}\cdot 1}\cdot exp\{\frac{-(x_2-1)^2}{2\cdot1^2}\}\cdots\frac{1}{\sqrt{2\pi}\cdot 1}\cdot exp\{\frac{-(x_{30}-1)^2}{2\cdot1^2}\}=(\frac{1}{\sqrt{2\cdot\pi}})^{30}\cdot exp\{-\frac{1}{2}\cdot\sum_{i=1}^{30}(x_i-1)^2\}= (\frac{1}{\sqrt{2\cdot\pi}})^{30}\cdot exp\{-\frac{1}{2}\cdot\sum_{i=1}^{30}(x_i-1)^2\}$

Next likelihood quotient and NP lemma:

$\frac{L(\mu_0=0|x)}{L(\mu_1=1|x)}=\frac{(\frac{1}{\sqrt{2\pi}})^{30}}{(\frac{1}{\sqrt{2\pi}})^{30}}\cdot \frac{exp\{-\frac{1}{2}\sum_{i=1}^{30}x_i^2 \}}{exp\{-\frac{1}{2}\sum_{i=1}^{30}(x_i-1)^2}\}= exp\{-\frac{1}{2}\sum_{i=1}^{30}x_i^2 +\frac{1}{2}\sum_{i=1}^{30}(x_i-1)^2 \} \leq k$

$-\frac{1}{2}\sum_{i=1}^{30}x_i^2 +\frac{1}{2}\sum_{i=1}^{30}(x_i-1)^2\leq \log k$

$-\frac{1}{2}\sum_{i=1}^{30}x_i^2 +\frac{1}{2}\sum_{i=1}^{30}(x_i^2-2\cdot x_i + 1)\leq \log k$

$-\frac{1}{2}\sum_{i=1}^{30}x_i^2 +\frac{1}{2}\sum_{i=1}^{30}x_i^2-2\cdot \frac{1}{2}\sum_{i=1}^{30} x_i + \frac{1}{2}\sum_{i=1}^{30}1\leq \log k$

$-\frac{1}{2}\sum_{i=1}^{30}x_i^2 +\frac{1}{2}\sum_{i=1}^{30}x_i^2- \sum_{i=1}^{30} x_i + 30 \leq \log k$

$- \sum_{i=1}^{30} x_i + 30 \leq \log k$

$\frac{\sum_{i=1}^{30} x_i}{30} \geq \frac{-\log k + 30}{30}$

$\frac{\sum_{i=1}^{30} x_i}{30} \geq k^{\ast}$

$T(X) = \frac{\sum_{i=1}^{30} x_i}{30} = \bar{x}$

$T(X)\big|_{H_0:\mu_0=0}\sim N(0, \frac{\sigma}{\sqrt{n}})$ $n=30,\sigma = 1$ so $\frac{\sigma}{\sqrt{30}}=\frac{1}{\sqrt{30}}$

$\alpha=P(T(X)>k^{\ast}\big|H_0)=0.05$

$P(T(X)<k^{\ast}\big|H_0)=0.95$ and I need to find that quantile. Using R I typed qnorm(0.95,0,1/sqrt(30)) and get $0.3$ and this is $k^{\ast} = 0.3$

First and most important question is: Are my calculations ok I did I mess something up? Additional questions (I'm not sure) - I can write that $T(X)\big|_{H_0:\mu_0=0}\sim N(0, \frac{1}{\sqrt{30}})$ by CLT?

1.Yes, your argument is correct using N-P lemma for simple hypothesis. It is the most powerful test in the parametric setting. For non-parametric setting there exists no most powerful test, just better tests. And for convenience if density function is a monotone function of sufficient statistics ,$T(x)=\bar{X}$. Then you can use the sufficient statistics directly in N-P lemma construction and there is no need to go through all the steps. I think it is called Karlin's lemma?check

2.I can write that $T(X)\big|_{H_0:\mu_0=0}\sim N(0, \frac{1}{\sqrt{30}})$ by CLT? Since you already assume X's are i.i.d coming from normal distribution, you do not need CLT now and the linear combination of X's is directly normal distribution of your interest.

hope this help.