Rishabh Singh
HomeAboutServicesProjectsOpen SourceBlogVisitorsContact

v2025 · Next.js + Tailwind

All Posts
Home/Blog/Confidence Interval vs Prediction Interval Explained
StatisticsLinear RegressionData Science

Confidence Interval vs Prediction Interval Explained

An interactive simulation showing why CI and PI are fundamentally different things. One band covers the mean line. The other catches new individual points.

July 3, 202612 min readRishabh Singh

A confidence interval (CI) estimates the range where the average response lies; a prediction interval (PI) estimates the range where a single new observation will fall. Because individual observations scatter around the mean, the PI is always wider than the CI at the same confidence level — often several times wider in typical regression settings. Both intervals narrow as sample size grows, but only the CI can shrink toward zero width: the PI's floor is set by the irreducible noise in the data itself. Use a CI when the question is about the model's estimate ("what is the average effect of X?") and a PI when it is about a future case ("what value should I expect next time?"). Confusing the two is the most common interval mistake in applied regression — and the interactive simulation below lets you see the difference directly.

Two bands, two entirely different questions

When a regression model draws a line through data, it answers one question: what is the average response at this X value? But the moment you put that line in front of a stakeholder, two more questions always follow — and they require completely different bands to answer honestly.

The first question is about the line itself: if you re-ran this study with a fresh sample, where would the regression line land? This is the Confidence Interval (CI) — uncertainty about the mean response.

The second is about one specific new observation: given a territory you've never seen before, where will its actual number actually land? This is the Prediction Interval (PI) — uncertainty about a single draw from the distribution.

They look like two concentric ribbons on a plot. The teal inner band is the CI. The clay outer band is the PI. They're not the same thing, and substituting one for the other is a quiet, expensive mistake.

The CI answers where is the average? The PI answers where will the next point be? One shrinks to zero as your sample grows. The other never shrinks past the noise floor.

Explore it

The simulation below uses a sales-territory example: each dot is a territory, X is monthly detailing calls to doctors, Y is new prescriptions written. A few things worth observing while you interact:

  • n ↑ The teal CI band tightens steadily toward the line. The clay PI band barely moves. More data nails down where the line is, but doesn't tame individual scatter.
  • noise Both bands widen, but the PI widens faster because it absorbs the full variance of individual territories.
  • 90/95/99 Confidence level scales both bands through the t-critical value. The PI stays outside the CI at every level.
  • hover See the exact CI ± and PI ± at any X. Both grow as you move toward the edges — the leverage effect.
Linear regression · seeing CI vs PI
Best-fit line, with both uncertainty bands

Each dot is a sales territory. X is monthly detailing calls to doctors, Y is new prescriptions. Watch how the teal CI band hugs the line while the clay PI band stretches to catch the points.

Controls
Show / hide
Data points
Best-fit line
CI band (the line)
PI band (new point)
Mean-of-X marker
Best-fit line
CI band
PI band
Territory
Fitted line
–
Rx per extra call
Points inside CI
–
low: CI is not about points
Points inside PI
–
should sit near the level
PI vs CI width
–
at the mean of X

What the math is actually saying

Both intervals use the same t-critical value and the same residual standard deviation s. The only difference is one term inside a square root:

The only difference between CI and PI
SEmean(x) = s · √( 1/n + (x − x̄)² / Sxx )
SEpred(x) = s · √( 1 + 1/n + (x − x̄)² / Sxx )

That "1 +" is the entire difference. It represents the variance of a single new observation around the true mean — variance that exists independently of how large your sample is. As n → ∞, SEmean → 0, but SEpred → s. You can have a million data points and the PI will still be wide if the underlying process is noisy. The noise is real; it doesn't average away.

Both formulas also contain (x − x̄)² / Sxx, which grows as you move away from the center of your data. This is why both bands pinch at the mean of X and flare toward the edges — the model is most certain where it has seen the most data, and extrapolation compounds every source of uncertainty.

What does each term in the formula actually do?

The full interval is estimate ± t-critical × SE. Walking through every ingredient once removes the mystery permanently:

  • s — the residual standard deviation. The typical vertical miss of the fitted line, computed from the residuals as √(Σe² / (n−2)). It divides by n−2, not n, because two degrees of freedom were spent estimating the slope and intercept. Every other term in both formulas is a multiplier on s — it sets the scale of all uncertainty.
  • 1/n — the "where is the line's height?" term. Uncertainty about the average level of the line at the center of the data. Exactly like the standard error of a mean, it melts away as sample size grows: quadruple n, halve this contribution.
  • (x − x̄)² / Sxx — the "where is the slope pointing?" term. Uncertainty about the slope, felt more strongly the further you predict from the center. At x = x̄ it is exactly zero — slope error pivots the line around its center, so the center is immune. Sxx = Σ(x − x̄)² in the denominator says: the more spread out your X values, the better the slope is pinned down.
  • 1 (PI only) — the "individuals scatter" term. The variance of one new observation around the true mean, in units of s². Note that it enters as a constant while the other two terms shrink with n — which is why, for even moderate samples, this single term dominates and the PI ends up several times wider than the CI.
  • tα/2, n−2 — the confidence dial. The t-critical value converts a standard error into an interval at your chosen level. At 95% with a large sample it approaches 1.96; with small samples it inflates (2.306 at n = 10) to pay for estimating s from limited data. Moving from 95% to 99% widens both bands by the same multiplicative factor — it never changes their ratio.

What do the numbers look like? A worked example

Take a deliberately small dataset: n = 10 territories, with call volumes x = 1, 2, …, 10. Suppose the fitted line is ŷ = 20 + 5x, the residual standard deviation is s = 4 prescriptions, and we want 95% intervals. The fixed pieces: x̄ = 5.5, Sxx = Σ(x − x̄)² = 82.5, and t0.025, 8 = 2.306.

At the center, x = 5.5 (predicted ŷ = 47.5): the leverage term is zero, so SEmean = 4 × √(1/10) = 1.26, giving a CI half-width of 2.306 × 1.26 ≈ ±2.9 → CI ≈ [44.6, 50.4]. The PI uses √(1 + 1/10) = 1.049, so SEpred = 4.20 and the half-width is 2.306 × 4.20 ≈ ±9.7 → PI ≈ [37.8, 57.2]. Same line, same data — the PI is 3.3× wider.

Away from the center, x = 8 (predicted ŷ = 60): now (x − x̄)² / Sxx = 6.25 / 82.5 = 0.076. SEmean = 4 × √(0.100 + 0.076) = 1.68 → CI half-width ≈ ±3.9 → [56.1, 63.9]. SEpred = 4 × √(1.176) = 4.34 → PI half-width ≈ ±10.0 → [50.0, 70.0]. Both bands widened, but the CI grew proportionally more — leverage hurts the mean estimate hardest, while the PI was already dominated by the irreducible "1".

Now imagine collecting a thousand territories instead of ten. The 1/n and leverage terms vanish, t drops to 1.96, and the CI half-width collapses toward zero — but the PI half-width converges to 1.96 × 4 ≈ ±7.8 and stops. No amount of data buys you a tighter promise about a single territory than the noise itself allows. That is the entire CI-vs-PI story in one number.

When to use each

Confidence Interval (CI)Prediction Interval (PI)
Question answeredWhere is the average response at this X?Where will one new observation land at this X?
Uncertainty aboutThe regression line (mean estimate)The line plus individual scatter
Width vs sample sizeShrinks toward zero as n growsNever shrinks below the noise floor (σ)
Relative widthNarrower — inner bandAlways wider — outer band
Typical useSignificance tests, average-effect estimates, research claimsForecasting one case, thresholds, quota / inventory decisions
Wrong-tool failure—Using a CI here understates risk for individual outcomes

Use CI when asking about the population

  • Testing whether detailing calls have a significant effect on prescriptions at the population level
  • Estimating the average lift across all territories with a given call volume
  • Publishing research about the mean response curve
  • Comparing two groups — "does group A average higher than group B?"

Use PI when deciding about one case

  • Forecasting one specific territory's prescription count next quarter
  • Deciding whether a single new patient will respond to a treatment
  • Setting an inventory threshold for one SKU at one store
  • Any time the question is "what will this observation be?" not "what is the average?"

If your boss asks 'will this territory hit quota next quarter?' — the CI band is the wrong tool. A CI that says ±12 prescriptions around the mean tells you nothing about whether one territory will land inside or outside target. You need the PI. And it will almost always be wider than you hoped.

What if the residuals aren't normal? The bootstrap alternative

Everything above leans on the classical assumptions: residuals that are roughly normal, with constant variance across X. Real data misbehaves — revenue residuals are right-skewed, count data has variance that grows with the mean, and outliers fatten the tails. When that happens, the t-based formulas produce intervals with the wrong coverage: a "95%" PI that actually captures 88% of new points is worse than no interval, because it carries false confidence.

The standard escape hatch is the bootstrap — let the data supply its own distribution instead of assuming one. For a CI on the mean response: resample your n observations with replacement, refit the regression, record the fitted value at your target x, and repeat a few thousand times. The 2.5th and 97.5th percentiles of those fitted values form the confidence band — no normality assumption anywhere.

For a PI, one resampled line isn't enough — you must also add back individual scatter. The common recipe (residual bootstrap) draws a random residual from the observed residual pool and adds it to each resampled prediction, so the percentile interval reflects both line uncertainty and point noise. A close cousin, quantile regression, gets there even more directly: fit the 2.5th and 97.5th percentile lines themselves and read the prediction band straight off them. The trade-off is honest: bootstrap intervals cost compute instead of assumptions, and they inherit whatever quirks your sample has — with n = 10 they are no magic fix. But from a few dozen observations up, they are the pragmatic default whenever a residual plot looks skewed, heavy-tailed, or fan-shaped.

How do these intervals get misused in industry?

The CI/PI confusion isn't an academic quibble — it shows up in the same few costly patterns everywhere:

  • Quota and target setting with CI bands. A revenue model's CI says the average territory at this call volume lands in [56, 64]. Planning then sets each individual quota inside that band — and half the field force "misses" targets that were never statistically achievable for individuals. Anything that judges single units — territories, stores, SKUs, reps — needs the PI. This is the single most common interval mistake in business forecasting.
  • A/B test readouts that promise individual outcomes. An experiment reports "the new flow lifts conversion by 2.1% (95% CI: 1.4% to 2.8%)." That is a statement about the average effect — correct and useful. The misuse is the follow-on slide: "so each region should expect 1.4–2.8% lift." Individual regions vary far more than the mean does; several will see zero or negative lift even when the average effect is real. Classification metrics have an exact analogue of this trap — a single headline number hiding per-case behavior — which is why you read the full confusion matrix, not just accuracy.
  • Forecast charts with unlabeled bands. Dashboards routinely shade "the uncertainty" without saying which uncertainty. A demand forecast wearing a CI band looks reassuringly tight and drives understocking; the honest PI band is wider and uglier, which is precisely its value. If a chart doesn't label its band, assume it's the flattering one.
  • Shrinking the band by collecting more data. Teams sometimes respond to a wide PI with "let's gather more history." More data tightens the CI, refines the estimates — and leaves the PI floor untouched, because the floor is the process noise itself. The fix for a wide PI is reducing real-world variance (or accepting it), not more rows.

For more on the foundations that make this work, see Linear Regression in a Minute.

Related Reading
Linear Regression in a Minute
The line, OLS derivation, assumptions, and diagnostics — the foundations that make CI and PI meaningful.
Back to Blog

© 2026 Rishabh Singh · Data Scientist & AI Engineer

PrivacyGitHubLinkedInMedium