1.3.21 · D3Probability & Statistics

Worked examples — Confidence intervals

3,639 words17 min readBack to topic

This is a worked-examples deep dive for Confidence intervals. The parent note built the formulas; here we hammer them against every kind of input a confidence-interval problem can throw at you — big samples, tiny samples, proportions, differences of proportions, differences of means, one-sided questions, and the degenerate edges where the formula almost breaks.

Figure s01 (read this first): the black curve is the sampling distribution of the mean; the red bar is the confidence-interval "net" of half-width thrown around the observed (black dot). The true (black cross) is fixed — the net is what moves from sample to sample. Every example below just resizes this red bar.


The scenario matrix

Before working anything, let us enumerate every case class a CI problem can be. Rather than a dense grid, read the decision tree below — it is the same content in visual-first form, and each leaf names the example that fills it.

Figure s02 (the map of this whole page): follow the arrows to land on your case. The red leaf ("small ⇒ use ") is the one beginners most often get wrong. Each leaf is tagged with its example number.

What are you estimating?

a mean

a proportion

a difference

sigma known

Cell A - use z - Ex 1

sigma unknown

n at least 30

Cell B - use z - Ex 2

n under 30

Cell C - use t - Ex 3

normal ok

Cell D - binomial SE - Ex 4

extreme or tiny n

Cell D-edge - Wilson - Ex 4b

two proportions

Cell E - add variances - Ex 5

two means

Cell E2 - add variances - Ex 5b

only a lower bound

Cell F - all alpha one tail - Ex 6

n equals 1 or zero spread

Cell G - degenerate - Ex 7

choose n first

Cell H - invert - Ex 8

raise confidence

Cell I - scaling - Ex 9

The dials for each cell:

  • Confidence dial: (95%), (99%), (90% two-sided or 95% one-sided).
  • Spread dial: if known, else (sample std, with the from Confidence intervals).
  • Shrink dial: .

Worked Examples

Cell A — mean, σ known

Cell B — mean, σ unknown, large n

Cell C — mean, σ unknown, small n

Figure s03 (why small demands ): the black curve is the standard normal; the red curve is the -distribution with . Notice the red curve's fatter tails — that is why its 90% cutoff (red dashed, at 2.132) sits further out than the normal's (black dashed, at 1.96). Fatter tails = wider net = honest extra caution for tiny samples. This is the picture behind Example 3, Step 4.

Cell D — a proportion

Cell E — difference of two proportions

Cell E2 — difference of two means

Cell F — one-sided bound

Cell G — degenerate inputs

Cell H — sample-size planning

Cell I — exam twist: raise the confidence


Recall

Recall Which cell: 400 latency samples, σ unknown?

Cell B — σ unknown but , so and we use . ::: Use because large makes .

Recall Two 95% CIs overlap. Are the estimates significantly different?

Not necessarily — overlap is a weak test. Compute the CI of the difference (Ex 5). ::: If that interval excludes 0, they differ significantly.

Recall Your test accuracy is 10-for-10. Why not report [1.0, 1.0]?

Because makes the normal , an artifact. Use the Wilson interval, giving about . ::: Extreme proportions break the normal approximation.

Recall To halve a margin of error, multiply

by ___? 4 — because , so precision costs the square of the improvement factor.