# Finding minimum value of observation for a given power in hypothesis testing.

Let $$X_{1}, \ldots, X_{n}$$ be a sample from the distribution $$\mathrm{N}(\mu, 1)$$ and consider testing $$H_{0}: \mu=\mu_{0}$$ versus $$H_{1}: \mu=\mu_{1}$$ where $$\mu_{0}<\mu_{1}$$ are known numbers.
(a) For a given level $$\alpha,$$ find the most powerful test.
(b) Calculate the power
(c) For given $$\mu_{0}, \mu_{1}, \alpha,$$ determine the minimal number of observations needed to have power at least $$\beta$$ (i.e., to reject $$H_{0}$$ with probability at least $$\beta$$ when $$H_{1}$$ holds).

Using Neyman Pearson lemma I have found the test statistic to be $$\bar X$$ and reject $$H_{0}$$ if $$\bar X > k$$, where $$k= z_\alpha / \sqrt{n} + \mu_0$$ .

And calculated the power to be Power = P{Reject $$H_0$$} = P{$$Z> z_\alpha - \sqrt{n} (\mu-\mu_0)$$}

But for the Part (c) I don't know how to find the minimum number of observation for given condition.
I think I have to solve the equation $$\beta = P_{\mu_1}\{\bar X > z_\alpha / \sqrt{n} + \mu_0 \}$$ = P{$$Z> z_\alpha - \sqrt{n} (\mu_1-\mu_0)$$}
But I don't know how to solve this for $$n$$.

As you found, UMP test is given by Neyman Pearson's Lemma with rejection region

$$\mathbb {P}[\overline{X}_n>k|\mu=\mu_0]=\alpha$$

Now $$\overline{X}_n>k$$ is your decision rule ($$k$$ now is fixed) and you can calculate the power ( usually indicated with $$\gamma$$ because $$\beta$$ is normally used for type II error)

$$\mathbb {P}[\overline{X}_n>k|\mu=\mu_1]=\gamma$$

Understood this, finally fix $$\gamma$$ and get $$n$$

Example

$$\mu_0=5$$

$$\mu_1=6$$

$$\alpha=5\%$$

$$n=4$$

The critical region is

$$(\overline {X}_4-5)2=1.64\rightarrow \overline {X}_4=5.8224$$

$$\overline {X}_4\geq 5.8224$$

and you can calculate the power

$$\gamma=\mathbb {P}[\overline {X}_4\geq 5.8224|\mu=6]=1-\Phi(-0.36)\approx 64\%$$

Now suppose you want a fixed power $$\gamma \geq 90\%$$, simply re-solve the same inequality in $$n$$

$$\mathbb {P}[\overline {X}_n\geq 5.82|\mu=6]\geq 0.90$$

Getting

$$(5.8224-6)\sqrt{n}\leq-1.2816$$

That is

$$n\geq\Bigg \lceil \Bigg(\frac{1.2816}{0.1776}\Bigg)^2\Bigg\rceil=53$$

You can state it in terms of the CDF $$\Phi(z)=P(Z \le z)$$; I don't think there is a way to avoid it.

\begin{align} \beta &\le 1 - \Phi(z_\alpha - \sqrt{n}(\mu_1-\mu_0)) \\ \Phi^{-1}(1-\beta) &\ge z_\alpha - \sqrt{n} (\mu_1 - \mu_0) \\ \sqrt{n} &\ge \frac{z_\alpha - \Phi^{-1}(1-\beta)}{\mu_1 - \mu_0} \end{align}