Calculator
Enter the data to get the confidence interval using Student's t distribution.
Mean observed in your sample; it is the center of the confidence interval. E.g. 245.3 ms of average response time.
Standard deviation calculated from the sample (with divisor n−1); it measures how much the data vary around x̄.
Number of observations in the sample. It determines the degrees of freedom of Student's t (df = n − 1) and the standard error.
Probability that the procedure produces an interval containing the true population mean. 95% is the usual standard.
Explanation
In practice, the population standard deviation \(\sigma\) is rarely known exactly. When it is estimated from the sample data itself using \(s\), extra uncertainty appears, which Student's t distribution with \(n-1\) degrees of freedom models correctly.
With large samples (n ≥ 30), Student's t converges to the standard normal and both intervals give very similar results. For small samples, t produces wider intervals, correctly reflecting the greater uncertainty.
Formula
Let \(C\) denote the confidence level and \(\alpha=1-C\) the total area outside the interval. For 95% confidence, \(C=0.95\), \(\alpha=0.05\) and \(\alpha/2=0.025\) in each tail.
\( \bar{x} \pm t_{\alpha/2,\, n-1} \cdot \dfrac{s}{\sqrt{n}} \)
- \(\bar{x}\): observed sample mean.
- \(t_{\alpha/2,\, n-1}\): critical value of Student's t with \(n-1\) degrees of freedom.
- \(s\): sample standard deviation (with divisor \(n-1\)).
- \(n\): sample size.
The margin of error is \(E = t_{\alpha/2,\, n-1} \cdot s/\sqrt{n}\) and the interval is \([\bar{x} - E,\; \bar{x} + E]\).
Worked example
The response time (in ms) of a web service is measured over 15 requests: \(\bar{x} = 245.3\) ms, \(s = 38.7\) ms. With 95% confidence (\(C=0.95\), \(\alpha=0.05\)) and \(df = 14\):
\( 245.3 \pm 2.145 \cdot \frac{38.7}{\sqrt{15}} \approx [223.9,\; 266.7] \text{ ms} \)
Assumptions of the t interval
- The sample is random and independent.
- The variable is normally distributed in the population (especially important for small samples). For large n, the central limit theorem justifies it even if the distribution isn't exactly normal.
- \(\sigma\) is unknown and estimated with \(s\).
How to interpret the result
The interval \([L, U]\) is the range of values of the population mean \(\mu\) compatible with the observed data and the chosen confidence level. The frequentist meaning is the following: if you repeated the experiment many times — each time taking a sample of the same size and building the CI with the same procedure — approximately \(C \times 100\%\) of those intervals would contain the true value of \(\mu\). It is not a probability statement about the specific parameter, but about the long-run reliability of the method.
The width of the interval directly communicates the precision of the estimate. A narrow interval indicates greater precision: it is obtained with larger samples, lower variability in the data, or by accepting a somewhat lower confidence level. A wide interval is not an error in itself; it honestly reflects that with that sample there is a lot of uncertainty about \(\mu\). In the chart, the green region is the confidence zone under the t curve and the red tails each represent \(\alpha/2\) of the total area; the critical values \(\pm t_{\alpha/2,\,n-1}\) delimit those regions.
- Connection with hypothesis testing: if a reference value \(\mu_0\) falls outside the interval, the data would reject \(H_0\!: \mu = \mu_0\) at significance level \(\alpha = 1 - C\) in the equivalent two-sided test. If \(\mu_0\) falls inside, there is no evidence to reject it.
- Effect of sample size: doubling \(n\) reduces the margin of error by a factor of \(\sqrt{2} \approx 1.41\); to halve it you need to quadruple \(n\).
- Effect of confidence level: increasing confidence from 95% to 99% widens the interval because the critical value \(t\) grows; demanding more certainty comes at the cost of less precision.
Frequently asked questions
- Why use t instead of z? Because estimating \(\sigma\) with \(s\) introduces extra uncertainty; the t distribution has heavier tails to account for it.
- When do t and z converge? For n ≥ 30 the difference is practically negligible in most applications.
- Do I need the data to be normal? For small n it does matter. For large n, the CLT guarantees that \(\bar{x}\) is approximately normally distributed.
Reference: Confidence interval — Wikipedia