# Probability of Type II error for simple hypothesis

I'm working through Intro to Probability and Statistics... and I'm a little confused about how to calculate the probability of a type II error, particularly as it relates to a simple hypothesis test, and would appreciate some clarification on this.

To explain my confusion, in 8.4.3 of the book, he gives example 8.2.4:

Let $$X1,X2,...,Xn$$ be a random sample from a $$N(\mu,\sigma^2)$$ distribution, where $$\mu$$ is unknown but $$\sigma$$ is known. Design a level $$\alpha$$ test to choose between

$$H_0: \mu=\mu_0$$,

$$H_1: \mu \neq \mu_0$$.

Which I understand completely. However, in 8.2.5 (just below), he asks:

For the above example (Example 8.24), find $$\beta$$, the probability of type II error, as a function of $$\mu$$.

Providing the solution:

\begin{align} \beta (\mu) &=P(\textrm{type II error}) = P(\textrm{accept }H_0 \; | \; \mu) \\ &= P\left(\left|\frac{\overline{X}-\mu_0}{\sigma / \sqrt{n}} \right| \lt z_{\frac{\alpha}{2}}\; | \; \mu \right). \end{align}

If $$X_i \sim N(\mu,\sigma^2)$$, then $$\overline{X} \sim N(\mu, \frac{\sigma^2}{n})$$. Thus,

\begin{align} \beta (\mu)&=P\left(\left|\frac{\overline{X}-\mu_0}{\sigma / \sqrt{n}} \right| \lt z_{\frac{\alpha}{2}}\; | \; \mu \right)\\ &=P\left(\mu_0- z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}} \leq \overline{X} \leq \mu_0+ z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}}\right)\\ &=\Phi\left(z_{\frac{\alpha}{2}}+\frac{\mu_0-\mu}{\sigma / \sqrt{n}}\right)-\Phi\left(-z_{\frac{\alpha}{2}}+\frac{\mu_0-\mu}{\sigma / \sqrt{n}}\right). \end{align}

I follow this until the end, where he jumps from:

\begin{align} &=P\left(\mu_0- z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}} \leq \overline{X} \leq \mu_0+ z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}}\right)\\ \end{align}

To:

\begin{align} &=\Phi\left(z_{\frac{\alpha}{2}}+\frac{\mu_0-\mu}{\sigma / \sqrt{n}}\right)-\Phi\left(-z_{\frac{\alpha}{2}}+\frac{\mu_0-\mu}{\sigma / \sqrt{n}}\right). \end{align}

Further, since the alternative hypothesis is simply $$\mu_1 \neq 2$$, how exactly would one go about calculating this probability? What value of $$\mu$$ would be used here?

Would someone be able to clarify this, and elaborate on how to calculate the probability of a type II error given a simple hypothesis, such as this?

In $$\Pr\left(\mu_0- z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}} \leq \overline{X} \leq \mu_0+ z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}}\right)$$, $$\bar X\sim N(\mu,\frac {\sigma^2}n)$$, instead of standard normal distribution. We need to transform $$\bar X$$ into standard normal distribution by subtracting the mean and dividing by standard deviation.
$$\Pr\left(\mu_0- z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}} \leq \overline{X} \leq \mu_0+ z_{\frac{\alpha}{2}} \frac{\sigma}{\sqrt{n}}\right)$$ = $$\Pr\left(z_{\frac{\alpha}{2}}+\frac{\mu_0-\mu}{\sigma / \sqrt{n}} \leq \frac{\overline{X}-\mu}{\sigma/\sqrt n} \leq -z_{\frac{\alpha}{2}}+\frac{\mu_0-\mu}{\sigma / \sqrt{n}}\right)$$
Now $$\frac{\overline{X}-\mu}{\sigma/\sqrt n} \sim N(0,1)$$, so you can get \begin{align} &=\Phi\left(-z_{\frac{\alpha}{2}}+\frac{\mu_0-\mu}{\sigma / \sqrt{n}}\right)-\Phi\left(z_{\frac{\alpha}{2}}+\frac{\mu_0-\mu}{\sigma / \sqrt{n}}\right). \end{align} where $$\Phi$$ is CDF of standard normal distribution.
For the question aout the value of $$\mu$$, as $$\beta(\mu)$$ indicates that $$\beta$$ is the function of $$\mu$$. So when you plug in the different values of $$\mu$$, you get the different probability of type II error $$(\beta)$$.