The previous lessons described the standard error of a sample mean, and then the shape of the standardized mean. A confidence interval uses that standard error to build a random interval around the sample mean. A frequentist 95% interval is a statement about the long-run coverage of the procedure. After one interval has been computed, it either covers the fixed value $\mu$ or it does not; there is not then a 95% probability that $\mu$ lies in that particular interval.
What you will be able to explain
State the formulas for a $z$-interval, which uses a known population standard deviation $\sigma$, and a $t$-interval, which uses the sample standard deviation $s$. Explain the frequentist coverage interpretation. Say when those intervals have exact nominal coverage, and give a case — a small $n$ and a skewed population — where a $t$-interval can undercover, and where a $z$-interval can have strongly one-sided misses even if the overall hit rate is close to the nominal level. Say why a finite simulation is not a proof of exact coverage.
This experiment uses dimensionless values. Read first: Why averaging reduces noise — and when it does not and What the central limit theorem does — and what it does not. You will need the difference between the sample size $n$ in one interval and the number of repeated samples, the $\sigma/\sqrt{n}$ standard error, and the fact that the classical central limit theorem is a limit statement about the standardized mean, not a claim that a small sample is already normal. In the formulas below, $\bar{X}_n$ is the sample mean of $n$ independent, identically distributed observations, $\mu$ is the population mean, and $z_{1-\alpha/2}$ and $t_{n-1,1-\alpha/2}$ are the upper tail critical values of a standard normal and a Student's $t$ distribution with $n-1$ degrees of freedom. The $t$-interval uses
$$s=\sqrt{\frac{1}{n-1}\sum_{i=1}^n(X_i-\bar{X}_n)^2}.$$
The two intervals are
$$\bar{X}_n\pm z_{1-\alpha/2}\frac{\sigma}{\sqrt{n}},\qquad \bar{X}_n\pm t_{n-1,1-\alpha/2}\frac{s}{\sqrt{n}}.$$
Predict
A 95% $z$-interval has already been computed from one normal sample, using the known $\sigma$. Which statement is correct?
There is a 95% probability that $\mu$ lies in this already-computed interval. The 95% refers to the long-run share of intervals from this procedure that cover the fixed value $\mu$. This particular interval either covers $\mu$ or it does not. After the data are seen, $\mu$ is still a random variable, so it has a 95% chance of falling into the interval.
Predict before running the experiment. You may skip the question and come back later; nothing is locked.
Manipulate and observe
Start with the default: normal observations, $n=20$, a 95% $z$-interval with known $\sigma$, and seed 20261201. The chart already shows 80 intervals. The vertical line is the fixed $\mu$ used in the model. Intervals that cover $\mu$ are drawn solid; intervals that miss are dashed and marked. The first interval is already determined: in this default run it covers $\mu$. Read the empirical coverage, and how many misses lie entirely to the left or to the right of $\mu$. Then run toward 200 repetitions. A finite simulation can sit close to 95% without proving a theorem, and a single already-drawn interval is still only a hit or a miss.
Next choose the exponential model, then the more skewed chi-square model with one degree of freedom. Keep $n=5$ and the $z$-interval first. The overall coverage may stay near the nominal level, but almost all misses can sit on one side of $\mu$. Then switch to a $t$-interval, which uses the sample standard deviation $s$, still at $n=5$, and compare with $n=80$. The $t$-interval is not guaranteed to have 95% coverage when the observations are not normal.
Explain
Before the sample is drawn, a 95% confidence interval is a random interval $(L,U)$ whose coverage probability is $P(L\le\mu\le U)$. If the assumptions of the procedure hold, that probability equals $0.95$, or comes close to it in a large-sample approximation. The number $0.95$ belongs to the procedure under repeated sampling. After the sample has been observed and the numbers $\ell$ and $u$ have been computed, those endpoints are fixed. The unknown $\mu$ is also fixed. The interval $[\ell,u]$ either contains $\mu$ or it does not; it does not retain a 95% probability of containing $\mu$. This lesson uses that frequentist reading throughout.
For independent, identically distributed normal observations with a known $\sigma$, the $z$-interval has exact coverage $1-\alpha$ at every $n\ge 1$. For the same normal model when $\sigma$ is unknown and $s$ is used instead, the $t$-interval has exact coverage $1-\alpha$ at every $n\ge 2$. Those are statements about the random interval, not about one computed pair of endpoints. The $t$ critical value is larger than the normal critical value at a finite $n$, because $s$ adds variability; the two critical values approach each other as $n$ grows.
The same formulas can be used as approximations for a non-normal population that still has a finite, nonzero variance. The justification often given is the central limit theorem: $\sqrt{n}(\bar{X}_n-\mu)/\sigma$ tends in distribution to a standard normal. That is a limit statement. It does not give exact 95% coverage at $n=5$ or $n=20$, and there is no universal sample size at which the approximation suddenly becomes exact. A more skewed distribution can need a larger $n$.
For a right-skewed population such as the unit exponential or chi-square with one degree of freedom, a $z$-interval with the known $\sigma$ need not have exactly the nominal coverage at a small $n$. In the exponential and chi-square models used here, the exact coverage of that $z$-interval is in fact slightly above 95% at $n=5$, but the misses are strongly one-sided: almost every miss is an interval that lies entirely on one side of $\mu$. Overall coverage close to 95% is not the same as a well-balanced procedure. A $t$-interval, which is exact under normality, can undercover for the same skewed models at $n=5$, because $s$ moves with the sample mean. A finite simulation with a fixed seed can show these patterns; it cannot prove a coverage theorem.
The same independence and finite-variance conditions needed for $\sigma/\sqrt{n}$ and for the classical central limit theorem are needed here. Duplicating a recorded reading does not create independent data. If every observation has a shared offset and the interval is still built as if the mean were the un-offset $\mu$, coverage is not the nominal level; averaging did not calibrate the instrument, and an interval centered at the biased mean will miss the un-offset value. This lesson uses only models that have a mean and a finite, nonzero variance. The standard Cauchy case from the previous lesson is not a setting in which these $z$- or $t$-intervals are defined in the usual way.
A confidence interval for $\mu$ is also not a claim that 95% of the observations fall inside the interval. That would be a different object, such as a tolerance interval or a prediction interval for a new observation.
Practice and transfer
A colleague draws $n=5$ independent exponential observations, builds a 95% $t$-interval, and says the central limit theorem guarantees that about 95% of such intervals cover $\mu$, even at $n=5$. What is wrong with that claim? Use the experiment to compare a $t$-interval at $n=5$ with $n=80$ for the exponential or chi-square model. Feedback stays in this browser tab; the experiment does not store or transmit answers or learning analytics.
The same distinction appears in a measurement setting. Averaging independent sensor readings can make the mean more stable, and the central limit theorem can justify a normal approximation to that mean when $n$ is large enough and a variance exists. That is not a license to treat a 95% $t$-interval from five skewed readings as if it had exact 95% coverage.
Assumptions and reproducibility
Each repetition uses a fresh block of 80 pseudorandom values. The first $n$ numbers form one sample and one interval. Using the same seed and changing $n$ keeps the nested samples, so comparisons across $n$ are convenient, but those runs are not independent of one another. Within a single $n$, each repetition uses a different block.
The generator is Mulberry32, with a 32-bit seed set by the user. The default seed is 20261201. The values of $n$ are 5, 20, and 80, the confidence levels are 90%, 95%, and 99%, and the number of repetitions is at most 400. The standard normal critical value uses a published rational approximation whose absolute error, compared with a reference inverse, is less than $6\times 10^{-5}$ on the probabilities used here. The $t$ critical values are computed from the regularized incomplete beta function. Normal observations are generated by applying that same inverse-normal map to the uniforms; exponential observations use $-\log(1-U)$; chi-square observations with one degree of freedom are squares of those normal values. The $t$-interval uses the Bessel-corrected $s$, with $n-1$ in the denominator. If $s=0$, the $t$-interval shrinks to a point and covers $\mu$ only when the sample mean equals $\mu$. Resetting restores the normal model, $n=20$, a 95% $z$-interval, seed 20261201, and 80 initial repetitions, with a target of 200. The default chart is a finite sample: in this seed, 76 of the first 80 intervals cover $\mu$, with two misses on each side, and the first interval covers $\mu$.
For the unit exponential, $2n\bar{X}_n$ follows a chi-square distribution with $2n$ degrees of freedom, so the coverage of the known-$\sigma$ $z$-interval can be computed exactly. At $n=5$ and the 95% critical value used in the figure, that exact coverage is about $0.956$, with almost all of the miss probability on one side. The chi-square(1) $z$-interval has a similar exact calculation. Empirical summaries for the $t$-interval, and all on-screen counts, describe this finite simulation.
Related ideas
This lesson continues the sample-mean experiment on averaging and noise and the experiment on what the central limit theorem does. The Math topic page collects other mathematical experiments on the site. These links extend the idea; they are not extra prerequisites beyond the two earlier lessons.
References
NIST/SEMATECH, Confidence Limits for the Mean: https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm
StatLect, Confidence interval for the mean: https://www.statlect.com/fundamentals-of-statistics/set-estimation-mean
StatLect, Interval estimation and confidence intervals: https://www.statlect.com/fundamentals-of-statistics/set-estimation
NIST/SEMATECH, t Distribution: https://www.itl.nist.gov/div898/handbook/eda/section3/eda3664.htm
Concept connections
- Sampling models
- A description of how observations are generated. In this experiment the chosen distribution, independence, and sample size define that model.
- Central limit theorem
- A limit statement about the distribution of the standardized sample mean under conditions such as independent, identically distributed observations with a finite, nonzero variance. It is not a claim that a small sample is already normal, or that a 95% interval has exact coverage at every n.
- Confidence interval
- A random interval whose frequentist confidence level is the long-run coverage of the procedure. After the endpoints have been computed, the interval either covers the fixed parameter or it does not.
Continue with the averaging and noise lesson and the central limit theorem lesson if you have not read them yet. Those two lessons are the intended prerequisites.
