We want to estimate the population mean with regard to a single, quantitave variable. We know with certainty the population standard deviation, \(\sigma\). We have a sample of size \(n\) and popluation mean \(\bar{x}\).
To estimate the population mean using the normal distribution, one of the following conditions must hold:
Null hypothesis, \(H_0\): \(\mu = \mu_0\)
Alternative hypothesis, \(H_a\): \(\mu \ne/>/< \mu_0\)
\[ z = \frac{\bar{x} - \mu_0}{\frac{\sigma}{\sqrt{n}}} \]
Where Z is a standard normal random variable,
p = stats.norm.cdf(z)
p = 1 - stats.norm.cdf(z)
p = 2 * stats.norm.cdf(-abs(z))
\[ \text{C% confidence interval} = \bar{x} \pm z^\star \frac{\sigma}{\sqrt{n}}\\ \text{choose } z^\star \text{ s.t. area on standard normal distribution from }(-z^\star,z^\star)\text{ = C} \]
\[ m^\star = z^\star \frac{\sigma}{\sqrt{n}} \iff n = (\frac{z^\star \sigma}{m^\star})^2 \]
If you lack access to the true value of the population standard deviation, a one-sample t-test for means is more appropriate.
If you want to compare means across two diferent independent populations, a two-sample z-test for means is more appropriate.
A one-sample z-test conducted at confidence level \(\alpha\) will reject the null hypothesis if and only if the value corresponding to the null hypothesis, \(\mu_0\), is completely outside of the \(C = 1-\alpha\) confidence interval.