In a hypothesis test with Normal data, why do people use the t-statistic instead of some other statistic? [duplicate]

Suppose we have that $X_1, \ldots, X_n \sim N(\mu, \sigma^2)$ where $\sigma^2$ is known. If we wanted to test the hypothesis of:

$$H_0: \mu = \mu_0 \ \ \text{and} \ \ H_1: \mu \neq \mu_0$$

a lot of books just jump directly to using a z-score based test statistic of:

$$Z = \frac{\bar{X}-\mu}{\sigma/\sqrt{n}} \sim N(0,1)$$

However, I do not understand why or how they jump to this statistic aside from the fact it appears the normal distribution is easy to calculate from.

My question is, my understanding is that formally, we can choose any test statistic $T(X)$ such that:

$$P(T(X) \in R\mid H_0) = \alpha$$

where $R$ is a rejection region to be found and $\alpha$ the significance level.

I am wondering how one can formally derive the $Z$ score approach above? Thanks.

• For known $\sigma$ Z is N(0,1) when $\mu$=$\mu_0$ and is the uniformly most powerful test against other values of $\mu$. Jun 20 '17 at 3:21
• stats.stackexchange.com/questions/285654/… This is the correct link. The previous one was wrong. Jun 20 '17 at 3:36

Among all the tests of level $\alpha$, a natural optimality criterion is the notion of being uniformly most powerful (UMP) - the test maximizes the power against all alternatives in $H_1$.
In the case of the one-sided alternative $H_1:\mu>\mu_0$ (or $H_1:\mu<\mu_0$), the z-test is UMP, which is essentially a consequence of the Neyman-Pearson Lemma.
Unfortunately, for the two-sided alternative $H_1:\mu\neq \mu_0$, no UMP test exists (Example 2.4). However, if we restrict ourselves to considering only unbiased tests (we require power at least $\alpha$ against all alternatives), it can be shown that the z-test is uniformly most powerful among all unbiased tests (Example 2.6).