The estimation of a population mean given a random sample is a very common task. If the population standard deviation ($$\sigma$$) is known, the construction of a confidence interval for the population mean ($$\mu$$) is based on the normally distributed sampling distribution of the sample means (assured by the central limit theorem). Recall, that if the population from which the sample is taken is not normally distributed, the sample size $$n$$, should be $$>30$$.

The $$100(1-\alpha)\%$$ confidence interval for $$\mu$$ is given by

$CI: \bar x \pm z^*_{\alpha/2}\times \sigma_{\bar x}$ $\text{where}\qquad \sigma_{\bar x} = \frac{\sigma}{\sqrt{n}}$

The value of $$z^*_{\alpha/2}$$ corresponds to the critical value and is obtained from the standard normal table or computed with the qnorm() function in R. The critical value is a quantity that is related to the desired level of confidence. In other words, it is multiplied with the standard error, given by $$\sigma_{\bar x}$$, in order to widen or narrow the margin of error. Typical values for $$z^*_{\alpha/2}$$ are 1.64, 1.96 and 2.58, corresponding to confidence levels of 90 %, 95 % and 99 %.

The standard error ($$\sigma_{\bar x}$$) is given by the ratio of the standard deviation of the population ($$\sigma$$) and the square root of the sample size $$n$$. It describes the degree to which the computed sample statistic may be expected to differ from one sample to another. The product of the critical value and the standard error is called the margin of error. It is the quantity that is subtracted from and added to the value of $$\bar x$$ to obtain the confidence interval for $$\mu$$.