# Designing a uniformly most powerful test.

Let $X_1, ... , X_n$ be iid normally distributed random variables $N(\mu, \sigma^2)$, $\mu \in \Bbb{R}$, $\sigma^2 > 0$.

a) Design a uniformly most powerful test with significance level $\alpha$ for testing $H_0: \sigma^2 = \sigma^2_0$ vs $H_1: \sigma^2 > \sigma^2_0$.

b) Give a formula for the power of the test.

Let $\sigma^2_1 > \sigma^2_0$.

$\Lambda = \frac{L(\sigma^2_0)}{L(\sigma^2_1)}$ = $\frac{(\frac{1}{\sqrt{2\pi}})^n (1/\sigma^2_0)^{n/2} e^{-\sum (X_i - \mu)^2/\sigma^2_0}}{(\frac{1}{\sqrt{2\pi}})^n (1/\sigma^2_1)^{n/2} e^{-\sum (X_i - \mu)^2/\sigma^2_1}} \leq k$ for some $k < 1$.

$\implies e^{\frac{-\sum (X_i - \mu)^2}{2\sigma^2_0} + \frac{\sum (X_i - \mu)^2}{2\sigma^2_1}} \leq (\frac{\sigma^2_0}{\sigma^2_1})^{n/2}k$

Let $k_1 = (\frac{\sigma^2_0}{\sigma^2_1})^{n/2}k$.

We have $\frac{-\sum (X_i - \mu)^2}{2\sigma^2_0} + \frac{\sum (X_i - \mu)^2}{2\sigma^2_1} \leq \ln(k_1)$

$\implies \sum (X_i - \mu)^2[\frac{1}{2\sigma^2_1} - \frac{1}{2\sigma^2_0}] \leq \ln(k_1)$

$\implies \sum (X_i - \mu)^2 \geq \ln(k_1)[\frac{1}{2\sigma^2_1} - \frac{1}{2\sigma^2_0}]^{-1}$

$\implies \frac{\sum (X_i - \mu)^2}{\sigma^2_0} \geq \ln(k_1)[\frac{1}{2\sigma^2_1} - \frac{1}{2\sigma^2_0}]^{-1}(\frac{1}{\sigma^2_0})$.

Let $k_2 = \ln(k_1)[\frac{1}{2\sigma^2_1} - \frac{1}{2\sigma^2_0}]^{-1}(\frac{1}{\sigma^2_0})$.

We know that $\frac{\sum (X_i - \mu)^2}{\sigma^2_0}$ has chi-square with n degrees of freedom.

So we choose $k_2$ such that $P_{H_0}( \frac{\sum (X_i - \mu)^2}{\sigma^2_0} \geq k_2) = \alpha$

b) $P_{H_1}( \frac{\sum (X_i - \mu)^2}{\sigma^2_0} \geq k_2)$ $= 1 - \int^{k_2}_0$ $(\frac{1}{\Gamma(n/2)2^{n/2}})x^{n/2-1}e^{-x/2} dx$.