
From the normal curve to the confidence interval
Today we build one chain of reasoning, start to finish:

A probability distribution spreads probability across the possible outcomes — but how depends on the data:
The curve’s height is a density — probability per mm, not a probability. Density × width ≈ probability.
Density is a rate, so it is not capped at 1:
dnorm(0, sd = 0.1)= 3.989. Nothing is 399% likely — proof that height ≠ probability.
The normal is the density we lean on: symmetric, fixed by μ (where it sits) and σ (how wide), total area 1.
Lake I3: μ ≈ 265.6 mm, σ ≈ 28.3 mm — our curve. Every dataset has its own.

There is a different normal curve for every μ and σ. Nobody can tabulate infinitely many curves.
So we rescale every value into the same units — standard deviations from the mean:
Subtracting μ slides the curve to centre 0. Dividing by σ squeezes it to width 1.
The result is the standard normal distribution: μ = 0, σ = 1. One curve. One table.
A z-score is not a new measurement. It is the same fish, expressed as “how many SDs from average.”

Tip
z = (length − mean) / standard deviation
# A tibble: 4 × 3
lake length_mm z_score
<chr> <dbl> <dbl>
1 I3 266 0.0139
2 I3 290 0.862
3 I3 262 -0.127
4 I3 275 0.332
A fish of 266 mm gets z = 0. A fish one SD above average gets z = 1.
Standardizing changes the axis labels, not the shape.
That matters: standardizing does not make non-normal data normal. It only puts it on a common ruler. We come back to this in Part 3.

Because the standard normal is one fixed curve, its areas are fixed too:
Our I3 fish, counted directly:
[1] 81.8
Theory says 68%. We get 81.8%.
Hold that gap. It is the whole point of Part 3.

pnorm, qnorm, dnorm — which is whichAll three describe the same standard normal curve. They differ in what you hand them and what you get back.
| Function | You give it | You get back |
|---|---|---|
pnorm(z) |
a z | the area to the left of it |
qnorm(p) |
an area | the z that cuts it off |
dnorm(z) |
a z | the height of the curve |
p = probability, q = quantile — and they are inversesdnorm is the curve’s height, used to draw it. A height is not a probability — only area is
The z-table is pnorm() printed on paper: cumulative area to the LEFT of z.
One table works for every dataset — because every dataset gets standardized first. (Contrast the t-table later, which needs a row for each sample size.)

Step 1 — standardize.
\(z = \frac{300 - 265.61}{28.3} = 1.22\)
Step 2 — look it up. Row 1.2, column 0.02 → 0.8888
Step 3 — read it as biology.
Catch 100 fish in I3 and about 11 should beat 300 mm.
Same answer, in R — no table:

qnormThe table question can be asked the other way round, and in fisheries it usually is:
We had a length and wanted a probability. Now we have a probability and want a length.
“How big must a grayling be to land in the top 5%?” — the trophy-fish question, and the size-limit question.
qnorm(0.95) = 1.645 — the z with 5% above it[1] 312.2
Only 5% of I3 fish should exceed 312.2 mm.
Every number on this slide assumed the fish are normal. Do we know that?

The Shapiro-Wilk test asks one question, and its hypotheses run opposite to what you expect:
So:
A small p-value here is bad news, not a result. That reversal is why this test gets misread every semester.
Two cautions: with large n it flags departures too small to matter; with small n it misses ones that matter. Always read the Q-Q plot too — points on the line = normal.
p = 0.0002. The I3 fish are not normal. Every probability in Part 2 assumed they were — so let’s audit them against the fish themselves.
| normal theory | actual data | |
|---|---|---|
| within ±1 SD | 68% | 81.8% |
| 95th percentile | 312.2 mm | 310 mm |
| P(fish > 300 mm) | 11.2% | 7.6% |
The centre is fine. The tail is off by a third.
And the tail is exactly where inference lives — critical values, rejection regions, p-values all sit out in the tails.
This is why we check assumptions before trusting a p-value.
Everything so far described individual fish. Science usually asks about the mean. Those need different spreads.
| Question | Spread |
|---|---|
| How long is a single fish? | SD (s) |
| Where is the population mean? | SE (s/√n) |
Using SE where you meant SD makes your interval √n times too narrow.
We have one sample and one mean, 265.6 mm. The true μ is some other number we will never see. A confidence interval is our honest statement of how close we probably are.
The recipe: \(\bar{y} \pm (\text{critical value}) \times SE\)
What “95%” means: repeat the whole study many times, build an interval each time, and 95% of those intervals will contain μ. The figure shows 20 such studies — one misses.
Warning
The interpretation everyone gets wrong
❌ “There is a 95% chance μ is in my interval.”
✅ “95% of intervals built this way capture μ.”
μ is a fixed number — it is not moving around. The interval is what is random. Yours either caught μ or it didn’t; you don’t get to know which.

When the population σ is genuinely known, the critical value comes straight off the standard normal:
qnorm()Wider confidence costs a wider interval. You cannot be more certain and more precise at the same time — only a bigger n buys you both.

Look again at that formula. It needs σ, the population standard deviation. We have never once had it.
What we actually have is s, computed from our 66 fish. And s is itself an estimate — a different sample gives a different s.
Two sources of uncertainty, not one:
Using 1.96 accounts for the first and ignores the second. Intervals come out too narrow and we claim more precision than we earned.
Gosset hit exactly this at Guinness — tiny barley samples, σ never known. His fix: use a curve with fatter tails, so the critical value is bigger and the interval honest.
That curve is Student’s t.

Same bell shape as the normal, but heavier in the tails — that extra thickness is the price of estimating σ.
Important
The rule that matters: whenever σ is estimated from the sample, use t — at any sample size. “n > 30, use z” is a convenience from the era of paper tables, not a statistical law. R uses t always.

Only the multiplier changed: t in place of 1.96.
The bottom row (df = ∞) is 1.96: the t-table contains the z-table.

A sample of 9 fish: mean = 272.8, s = 37.81
“The 95% CI for mean length is 243.7–301.9 mm.”
Had we wrongly used 1.96, we’d have reported ±24.7 — an interval 15% too narrow, claiming precision we never had.

Tip
Ten fish from I3. Same mean, same SE — only the multiplier differs.
set.seed(42)
small_sample <- i3_df %>% slice_sample(n = 10)
s_mean <- mean(small_sample$length_mm)
s_se <- sd(small_sample$length_mm) / sqrt(10)
tibble(method = c("z (wrong)", "t (correct)"),
crit = round_half_up(c(1.96, qt(0.975, 9)), 3),
lower = round_half_up(s_mean - crit * s_se, 1),
upper = round_half_up(s_mean + crit * s_se, 1))# A tibble: 2 × 4
method crit lower upper
<chr> <dbl> <dbl> <dbl>
1 z (wrong) 1.96 237. 280.
2 t (correct) 2.26 234. 284.
R agrees:
The t interval is wider — and that extra width is the honest cost of not knowing σ.
A confidence interval asks where is μ? A hypothesis test asks is μ equal to some specific value? Same machinery, different question.
\(t = \frac{\bar{y} - \mu_0}{s / \sqrt{n}}\) — how many SEs is our mean from the claim?

Use when the question has a direction: are these fish longer than 285 mm? A shorter result would not interest us — it goes with H₀.
Reject H₀ only if our t exceeds +1.729.


Use when either direction would matter: do these fish differ from 285 mm? Longer or shorter, we want to know.
Important
Same α, same df, bigger critical value (2.093 > 1.729) — splitting α pushes each cutoff further out, so a two-tailed test is harder to pass.
Pick your tails from the question, before seeing the data. When in doubt, two-tailed — it is also R’s default.


Tip
Are I3 grayling different from a historical mean of 260 mm?
H₀: μ = 260 · Hₐ: μ ≠ 260
One Sample t-test
data: i3_df$length_mm
t = 1.6091, df = 65, p-value = 0.1124
alternative hypothesis: true mean is not equal to 260
95 percent confidence interval:
258.6481 272.5640
sample estimates:
mean of x
265.6061
Read the output in this order:
Tip
Are I8 fish longer than I3 fish? Directional → one-tailed.
Welch Two Sample t-test
data: length_mm by lake
t = -15.532, df = 161.63, p-value < 2.2e-16
alternative hypothesis: true difference in means between group I3 and group I8 is less than 0
95 percent confidence interval:
-Inf -86.66138
sample estimates:
mean in group I3 mean in group I8
265.6061 362.5980
lake is alphabetical, so R tests I3 − I8. “I8 longer” therefore means I3 − I8 is less than zero → alternative = "less".
Note “Welch Two Sample t-test” — R does not assume the two lakes have equal variances, and here that matters: sd(I3) = 28.3 mm but sd(I8) = 52.3 mm.
It is: the probability of data like ours if H₀ were true.
It is not:
Small p means detectable, not large. With n = 168, a biologically meaningless 2 mm difference can return p = 10⁻¹⁶.
So, every time:
p = 1.2e-16
The chain, end to end:
pnorm for areas, qnorm for cutoffsNote
Up next — t-Tests, then Power and Error, where Type I/II errors and statistical power get the full treatment they need.
Before next class — chapter PDFs are on Canvas:
| Today’s topic | Read |
|---|---|
| Normal distribution, z-scores | W&S Ch. 10 |
| Checking normality | W&S Ch. 13 |
| SE and confidence intervals | W&S Ch. 4 |
| The t-distribution | W&S Ch. 11 |
| Hypothesis tests, p-values | W&S Ch. 6; Gotelli Ch. 4 |
Note
📖 R for Data Science (2e)