Estimating a population mean given a random sample is a prevalent task. Suppose the population's standard deviation ($\sigma$) is known. In that case, the construction of a confidence interval for the population's 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}}$$$$where\ \ \ \ \ \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 directly in Python over the norm.ppf()
function derived from the scipy
package. The critical value is a quantity related to the desired confidence level. In other words, it is multiplied with the standard error, given by $\sigma_{\bar{x}}$, 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. The quantity is subtracted from and added to the value of $\bar{x}$ to obtain the confidence interval for $\mu$.
Citation
The E-Learning project SOGA-Py was developed at the Department of Earth Sciences by Annette Rudolph, Joachim Krois and Kai Hartmann. You can reach us via mail by soga[at]zedat.fu-berlin.de.
Please cite as follow: Rudolph, A., Krois, J., Hartmann, K. (2023): Statistics and Geodata Analysis using Python (SOGA-Py). Department of Earth Sciences, Freie Universitaet Berlin.