Sampling distributions — theory with the campus wifi, the chi-square, Student’s t and the F (and the six pings that proved me right too soon)

In the first week of term I measured six wifi pings in the library and went to IT Services to complain: my mean came out at 46 ms and they promised 40. I ran 1 - pnorm(46.03, 40, 8.02 / sqrt(6)), got 3 % and said it out loud: “if the 40 ms were true, a mean like this would be extremely rare”. The technician looked at my calculation and said one thing: “you took that standard deviation from your six pings”. He was right. With the standard deviation of the sample itself, the standardised mean is no longer a normal but a Student’s t with 5 degrees of freedom, and the probability goes from 3 % to 6 %. Still small, but not “extremely rare”. Today we see where that t comes from.

This topic is about what happens to a statistic, like the mean or the variance of a sample, when you change sample: each sample gives a different value, so the statistic is a random variable with its own distribution, the sampling distribution. If the population is normal, those distributions are known exactly and have names: the normal for the mean, the chi-square for the variance, Student’s t for the mean when you don’t know σ, and Snedecor’s F to compare two variances. We carry on from inequalities and limit theorems: there the mean was almost normal for large n; here, with normal populations, it is exactly normal for any n. The proofs, step by step, are in the sampling distributions proofs.

Before you start. For this topic you need to standardise a normal and use pnorm and qnorm, know how the mean and the variance of a sum of independent variables come out, and have seen the gamma (topic 4). The idea that holds everything up is just one: the mean or the variance of a sample changes from one sample to another, so it has its own distribution. The topic goes in this order. First, what a statistic is and why it is random. Then the mean: if the population is normal, so is the mean. Next, three new distributions, all three built from standard normals: the chi-square (adding up squares), used for the variance; Student’s t (a normal divided by the square root of a chi-square), used for the mean when you don’t know σ; and Snedecor’s F (one chi-square divided by another), used to compare two variances. At the end, two samples at once and a table to know which distribution to use. If you get lost, go back to the pings and ask yourself what would change if you measured on another afternoon.

The wifi we’ll use throughout

The example for the whole topic is the latency of the campus wifi: how long a ping to a university server takes to go and come back, in milliseconds. We measure it in two buildings:

  • In the Computer Science and Maths building, IT Services say the latency of one ping is a normal with mean 40 ms and standard deviation 6 ms: X∼N(40,6) X \sim N(40, 6) .
  • In the library, the routers are the same model (same standard deviation, 6 ms), but more people are connected and we suspect the mean is higher: Y∼N(μ2,6) Y \sim N(\mu_2, 6) .

And we have two real samples (made up, but shaped like real ones): 15 pings in Computer Science and 12 in the library.

compsci <- c(35.2, 41.2, 46.0, 47.7, 45.4, 43.0, 43.6, 30.5,
             46.0, 53.1, 32.7, 36.5, 46.3, 38.1, 39.7)   # 15 pings, in ms
library_ <- c(57.4, 52.9, 41.4, 37.3, 39.4, 47.8,
              46.0, 52.9, 58.8, 47.4, 38.3, 46.2)        # 12 pings, in ms
round(c(n = length(compsci), mean = mean(compsci),
        s2 = var(compsci), s = sd(compsci)), 2)
round(c(n = length(library_), mean = mean(library_),
        s2 = var(library_), s = sd(library_)), 2)

Output:

    n  mean    s2     s 
15.00 41.67 38.29  6.19 
    n  mean    s2     s 
12.00 47.15 52.55  7.25 

In Computer Science, the mean of the 15 pings is 41.67 ms and the sample standard deviation 6.19; in the library, 47.15 and 7.25 (the underscore in library_ avoids clashing with R’s library() function). Neither mean is exactly the population one, and neither standard deviation is exactly 6. Is that difference normal, or are IT Services wrong? To answer that you need to know how much the mean and the variance of a sample vary from one sample to the next. That is this topic.

Sample, statistic and sampling distribution

Before the names: three afternoons of five pings

Before the definitions, an experiment with the data you already have. Imagine the 15 Computer Science pings were not measured on one afternoon, but on three afternoons of five: the first five, the next five and the last five. Same building, same wifi, same population N(40,6) N(40, 6) . Does each afternoon give the same result?

AfternoonPingsMeanVarianceWhy they differ
135.2; 41.2; 46.0; 47.7; 45.443.1025.22Three pings above 45 pull the mean up
243.0; 43.6; 30.5; 46.0; 53.143.2466.8330.5 and 53.1 are far apart: the variance shoots up
332.7; 36.5; 46.3; 38.1; 39.738.6624.99This time more fast pings came up and the mean drops below 40

The wifi hasn’t changed and, even so, the mean goes from 38.66 to 43.24 and the variance from 24.99 to 66.83. The population stays still; what moves is the sample. That is why, before you measure, the afternoon’s mean is not a number: it is a random variable, which can come out as 43.10, 38.66 or anything else, each value with its probability. And if it has probabilities, it has a distribution. The whole topic is about finding out which one.

Look at the variance column too: it jumps around much more than the mean, from 25 to 67, almost three times as much. When we get to the chi-square you’ll see it with numbers.

Now, the official names for what you have just done: each afternoon is a sample; the afternoon’s mean and variance are statistics; and the distribution of all the values that could come out is the sampling distribution.

Three definitions, all three exam material:

  • Simple random sample (SRS) of size n: n random variables X1,…,Xn X_1, \dots, X_n that are independent and identically distributed (iid), with the population’s distribution. Each Xi X_i is “ping number i before you measure it”.
  • Statistic: a function of the sample that does not depend on any unknown parameter. The sample mean Xˉ=1n∑Xi \bar X = \frac1n \sum X_i is a statistic; Xˉ−μ \bar X – \mu is not if you don’t know μ.
  • Sampling distribution: the probability distribution of a statistic.
Check you’ve got it: with the 15 pings, are the slowest ping in the sample, the mean minus 40 and the mean minus μ statistics?

The first two are; the third is not. You get the slowest ping from the data and nothing else (with ours, 53.1). The mean minus 40 is too: 40 is a number you put in, the figure IT Services promise, not an unknown parameter (with our sample it is 1.67). The mean minus μ cannot be computed as long as you don’t know what μ is, so it is not a statistic, even though it is a random variable. That is why, later on, the mean standardised with σ only works if you know σ, and you need the t when you don’t.

The two statistics you will use most are the mean and the sample variance, which divides by n−1 n – 1 :

Xˉ=1n∑i=1nXi,S2=1n−1∑i=1n(Xi−Xˉ)2 \bar X = \frac{1}{n}\sum_{i=1}^n X_i, \qquad S^2 = \frac{1}{n-1}\sum_{i=1}^n \left(X_i – \bar X\right)^2

In R, mean() and var() compute exactly these two (var() divides by n−1 n – 1 , not by n).

From the population to the sampling distributionOn the left, the population of pings, a normal with mean 40 and standard deviation 6. In the center, three afternoons of 15 pings each, with their points and their mean in coral: 41.67 with variance 38.29, 43.43 with 66.95 and 37.69 with 32.78. On the right, the histogram of the means of 10,000 afternoons, centred on 40 and much narrower than the population.PopulationN(40, 6)latency of one pingμ = 40 msσ = 6 msafternoon 1 (our sample)x̄ = 41.67 s² = 38.29afternoon 2x̄ = 43.43 s² = 66.95afternoon 3x̄ = 37.69 s² = 32.78… and so on, 10,000 afternoons344046Samplingdistribution of x̄the 10,000 means
Each afternoon gives a different mean and variance. The histogram of thousands of means is the sampling distribution of x̄.

In the picture, each row is a different afternoon measuring 15 pings in Computer Science: the population is the same, but each sample gives its own mean and variance. If you repeat the experiment thousands of times and make a histogram of all the means, that histogram is the sampling distribution of Xˉ \bar X .

Before each calculation in this topic, ask yourself what is random. The data of your sample are fixed numbers (41.67 is a number); Xˉ \bar X is the variable that any sample would have given. Probabilities are computed on Xˉ \bar X , and then you look at where your 41.67 falls.

The sample mean

Whatever the population, if it has mean μ and variance σ², the sample mean and variance satisfy:

E(Xˉ)=μ,Var⁡(Xˉ)=σ2n,E(S2)=σ2 E(\bar X) = \mu, \qquad \operatorname{Var}(\bar X) = \frac{\sigma^2}{n}, \qquad E(S^2) = \sigma^2

The first says that the sample mean points, on average, at the population mean. The second, that it concentrates with n: its standard deviation is σ/n \sigma / \sqrt n , the standard error of the mean. The third is the reason for the n−1 n – 1 : with it, the sample variance points, on average, at σ². With n in the denominator it would fall short.

And if the population is also normal, the sample mean is exactly normal, for any n (no CLT needed):

Xi∼N(μ,σ) iid  ⟹  Xˉ∼N ⁣(μ,σn),∑i=1nXi∼N ⁣(nμ,σn) X_i \sim N(\mu, \sigma) \ \text{iid} \;\Longrightarrow\; \bar X \sim N\!\left(\mu, \frac{\sigma}{\sqrt n}\right), \qquad \sum_{i=1}^n X_i \sim N\!\left(n\mu, \sigma\sqrt n\right)

With the Computer Science wifi and 15 pings: Xˉ∼N(40, 6/15)=N(40, 1.549) \bar X \sim N(40,\ 6/\sqrt{15}) = N(40,\ 1.549) . We check it by simulating 10,000 afternoons of 15 pings:

set.seed(2026)
mean_15 <- replicate(10000, mean(rnorm(15, 40, 6)))   # 10,000 means of 15 pings
round(c(mean = mean(mean_15), sd = sd(mean_15), theoretical = 6 / sqrt(15)), 3)
hist(mean_15, freq = FALSE, breaks = 40, xlab = "mean of 15 pings (ms)", main = "")
curve(dnorm(x, 40, 6 / sqrt(15)), add = TRUE, lwd = 2)
curve(dnorm(x, 40, 6), add = TRUE, lty = 2)           # the one for a single ping

Output:

       mean          sd theoretical 
     40.013       1.574       1.549 
10,000 means of 15 pingsDensity-scale histogram of 10,000 simulated means of 15 pings, from 34 to 46 milliseconds, with the normal of mean 40 and standard deviation 1.549 in coral, which fits it. Dashed grey, the normal of a single ping, standard deviation 6, four times wider.0.00.10.2242832364044485256Mean of 15 pings (ms)densityN(40, 1.549)one ping: N(40, 6)histogram of 10,000 meansnormal of the meanone ping
What hist and the two curve calls draw. The mean of 15 pings hardly ever leaves 36-44; a single ping often does.

How to read it

  • mean 40.013: the mean of the 10,000 means is 40, the population mean. That is E(Xˉ)=μ E(\bar X) = \mu .
  • sd 1.574 against theoretical 1.549: the standard deviation of the means is that of one ping (6) divided by 15≈3.87 \sqrt{15} \approx 3.87 . Simulation and formula differ by two hundredths, which is the noise of simulating 10,000 means.
  • The picture: the histogram (grey) fits the narrow normal N(40,1.549) N(40, 1.549) (coral). The dashed curve is a single ping’s, N(40,6) N(40, 6) : four times wider. A single ping can come out at 30 or 50 without anything odd going on; the mean of 15 hardly ever leaves 36-44.

With that you can already answer the first real question: if IT Services are right, what is the probability that the mean of 15 pings comes out at 41.67 or more?

1 - pnorm(41.67, 40, 6 / sqrt(15))     # P(mean >= 41.67) if mu = 40 and sigma = 6

Output:

[1] 0.1405213

14 %: one afternoon in seven would give a mean like that or higher. Nothing odd. The Computer Science mean of 41.67 is compatible with IT Services’ 40 ms.

Using σ instead of σ/n \sigma / \sqrt n . 1 - pnorm(41.67, 40, 6) gives 0.39 and is about one ping, not the mean of 15. It is the same mistake as in the limit theorems topic: the mean concentrates with n \sqrt n .

Why does S² divide by n − 1?

Because the deviations are measured from Xˉ \bar X , which is computed from the same data and always sits “in the middle” of them. The sum ∑(Xi−Xˉ)2 \sum (X_i – \bar X)^2 comes out smaller than ∑(Xi−μ)2 \sum (X_i – \mu)^2 , and dividing by n−1 n – 1 instead of n compensates exactly. Look at it with 10,000 samples of only 5 pings (with few data it shows more):

set.seed(2026)
s2_n1 <- replicate(10000, var(rnorm(5, 40, 6)))     # var() divides by n - 1
s2_n  <- s2_n1 * 4 / 5                               # the same, divided by n
round(c(sigma2 = 36, mean_n1 = mean(s2_n1), mean_n = mean(s2_n)), 2)

Output:

 sigma2 mean_n1  mean_n 
  36.00   36.02   28.82 

Dividing by n−1 n – 1 , the mean of the 10,000 variances is almost 36, the population’s. Dividing by n, it stays around 28.8, which is 36⋅4/5 36 \cdot 4/5 : 20 % short. That is why S2 S^2 is called unbiased for σ² (you will meet the name properly in the topic on estimator properties).

The chi-square

Before the formula: add up squares of pings

Before the density, build the chi-square yourself with the Computer Science pings. Assume for a moment that IT Services are right, μ=40 \mu = 40 and σ=6 \sigma = 6 , and do three things with each ping:

  1. Standardise it: z=(x−40)/6 z = (x – 40)/6 . Now it is an N(0,1) N(0, 1) and it tells you how many standard deviations from 40 the ping landed.
  2. Square it: z2 z^2 . It no longer matters whether the ping was fast or slow, only how far away it landed. It is never negative.
  3. Add them up, one after another.

Some of the rows (the rest work the same way):

Pingx x z z z2 z^2 Running totalWhy
135.2−0.800.640.64Fast, but once squared it adds the same as a slow one
241.20.200.040.68Almost at 40: it adds hardly anything
346.01.001.001.68Exactly one standard deviation away: it adds 1
830.5−1.582.517.25Far from 40: an unusual ping weighs a lot
1053.12.184.7713.02The slowest one adds almost a third of the total
1539.7−0.050.0016.05The sum of the 15 squares

How much do you expect that sum to be? Each z2 z^2 has mean 1, because E(Z2)=Var⁡(Z)+E(Z)2=1+0=1 E(Z^2) = \operatorname{Var}(Z) + E(Z)^2 = 1 + 0 = 1 . With 15 terms, the sum has mean 15, and ours, 16.05, is close. Another afternoon would give another number: always positive, nearly always close to 15 and sometimes much larger, because one very slow ping is enough to make the sum shoot up. A positive distribution, with mean 15 and a long tail to the right: that is the chi-square with 15 degrees of freedom. And the 15 is nothing mysterious: it is how many squares you added. With that in mind, the formal definition:

To talk about the sample variance we need a new distribution. A positive continuous variable follows a chi-square with n degrees of freedom, χ2(n) \chi^2(n) , if its density is

f(x)=(1/2)n/2Γ(n/2) xn/2−1e−x/2,x>0 f(x) = \frac{(1/2)^{n/2}}{\Gamma(n/2)}\, x^{n/2 – 1} e^{-x/2}, \qquad x > 0

No need to memorise it: it is a gamma you already know from topic 4, χ2(n)=gamma(n/2, 1/2) \chi^2(n) = \text{gamma}(n/2,\ 1/2) . Its properties come from there:

PropertyFormula
Mean and varianceE(X)=n E(X) = n , Var⁡(X)=2n \operatorname{Var}(X) = 2n
Moment generating functionMX(t)=(1−2t)−n/2 M_X(t) = (1 – 2t)^{-n/2} , for t<1/2 t < 1/2
Sum of independent onesX1+⋯+Xk∼χ2(n1+⋯+nk) X_1 + \dots + X_k \sim \chi^2(n_1 + \dots + n_k)
Square of a standard normalZ∼N(0,1)⇒Z2∼χ2(1) Z \sim N(0, 1) \Rightarrow Z^2 \sim \chi^2(1)
Sum of n squared standard normalsZ12+⋯+Zn2∼χ2(n) Z_1^2 + \dots + Z_n^2 \sim \chi^2(n)

The last row is the definition worth remembering: a χ²(n) is the sum of n independent squared standard normals. The degrees of freedom count how many free terms there are. That is why it is positive, why its mean is n (each Zi2 Z_i^2 has mean 1) and why it is skewed: large squares pull to the right.

In R it has its four letters, with the degrees of freedom as second argument:

df_ <- 10
dchisq(5, df_)           # density at 5
pchisq(5, df_)           # P(X <= 5)
qchisq(0.95, df_)        # 95 % quantile: leaves 95 % on the left
qchisq(0.05, df_, lower.tail = FALSE)  # the same: leaves 5 % on the right
set.seed(2026); round(rchisq(3, df_), 2)
curve(dchisq(x, 2), 0, 40, ylab = "f(x)")
for (k in c(5, 10, 20)) curve(dchisq(x, k), add = TRUE)

Output:

[1] 0.06680094
[1] 0.108822
[1] 18.30704
[1] 18.30704
[1] 11.34  5.00  2.61
Chi-square densitiesFour chi-square densities, with 2, 5, 10 and 20 degrees of freedom, between 0 and 40. The one with 2 starts at 0.5 and falls like an exponential; those with 5, 10 and 20 have a hump that moves right, lower and wider, with the tail on the right.0.00.10.20.30.40.50510152025303540xf(x)χ²(2)χ²(5)χ²(10)χ²(20)mean n, variance 2n:it moves rightand widens
What the curve calls with dchisq draw. The more degrees of freedom, the more it looks like a bell.

How to read it

  • 0.0668 and 0.1088: the density at 5 and P(X≤5) P(X \le 5) . A χ²(10) has mean 10, so staying at 5 or below only happens 11 % of the time.
  • 18.307 twice: the 95 % quantile. With lower.tail = FALSE, R gives the value that leaves 5 % on the right, which is the same number. Both ways are fine; pick one and don’t mix them.
  • The picture: with 2 degrees of freedom the density starts high and falls (it is an exponential with mean 2); with 5, 10 and 20 a hump forms that moves right (the mean is n) and widens (the variance is 2n). With many degrees of freedom it looks more and more like a normal: it is a sum of many Zi2 Z_i^2 and the CLT does its job.

In R the chi-square is chisq. We call the degrees-of-freedom variable df_ because df is the F density function in R.

An example with the wifi. If you knew the true mean (μ = 40), each standardised ping (Xi−40)/6 (X_i – 40)/6 is an N(0, 1), so the sum of the 15 squares is a χ²(15). Which value does that sum stay below 95 % of the time?

qchisq(0.95, 15)                                     # P(sum((X - 40)/6)^2 <= q) = 0.95
sum(((compsci - 40) / 6)^2)                          # its value with our 15 pings

Output:

[1] 24.99579
[1] 16.04667

95 % of the time the sum stays below 25.00; with our pings it is 16.05, very ordinary for a χ²(15), whose mean is 15.

The sample variance: the χ²(n − 1)

Now the central result of the topic for the variance. If X1,…,Xn X_1, \dots, X_n is an SRS from an N(μ,σ) N(\mu, \sigma) :

(n−1)S2σ2∼χ2(n−1)and also Xˉ and S2 are independent \frac{(n-1)S^2}{\sigma^2} \sim \chi^2(n – 1) \qquad \text{and also } \bar X \text{ and } S^2 \text{ are independent}

Look at the degrees of freedom: n − 1, not n. The sum ∑(Xi−Xˉ)2/σ2 \sum (X_i – \bar X)^2 / \sigma^2 has n squares, but they are not free: the deviations Xi−Xˉ X_i – \bar X always add up to 0, so the last one is fixed by the others. One degree of freedom is lost by estimating μ with Xˉ \bar X .

Degrees of freedom, with three pings

The phrase “one degree of freedom is lost” makes more sense with small numbers. Take the first three Computer Science pings: 35.2, 41.2 and 46.0. Their mean is 40.8.

Pingxi x_i xi−xˉ x_i – \bar x Why
135.2−5.6Free: it depends on how long the first ping took
241.20.4Free: it depends on the second one
346.05.2Forced: it has to be 0−(−5.6)−0.4=5.2 0 – (-5.6) – 0.4 = 5.2 for the three to add up to 0

Deviations from the sample mean always add up to 0, because the mean sits right in the center of the data. So if I tell you two of them, you know the third without looking. With μ this doesn’t happen: the deviations from 40 are −4.8, 1.2 and 6.0, and none of them follows from the others. Both sums have three squares, but in the one around xˉ \bar x only two are free.

That is a degree of freedom: a number that can come out as anything it likes. With n pings and the sample’s own mean, n − 1 are free, and that is why (n−1)S2/σ2 (n-1)S^2/\sigma^2 behaves like a sum of n − 1 squared standard normals, not n. Besides, the sum around xˉ \bar x is always the smallest possible: with these three pings, 58.56 against 60.48 for the sum around 40. It is the same reason S2 S^2 divides by n − 1.

With 15 Computer Science pings, 14S2/36∼χ2(14) 14 S^2 / 36 \sim \chi^2(14) . We check it by simulating:

set.seed(2026)
s2_15 <- replicate(10000, var(rnorm(15, 40, 6)))     # 10,000 variances of 15 pings
u <- 14 * s2_15 / 36                                 # (n - 1) S^2 / sigma^2
round(c(mean_u = mean(u), var_u = var(u)), 2)        # a chi^2(14): mean 14, var 28
hist(u, freq = FALSE, breaks = 40, xlab = "14 S^2 / 36", main = "")
curve(dchisq(x, 14), add = TRUE, lwd = 2)
curve(dchisq(x, 15), add = TRUE, lty = 2)            # the 15-degree one, to compare

Output:

mean_u  var_u 
 14.01  28.54 
(n − 1)S²/σ² with 15 pingsDensity-scale histogram of 14 times the sample variance over 36, in 10,000 samples of 15 pings, from 0 to about 40. On top, the chi-square density with 14 degrees of freedom in coral, which fits the histogram and has mean 14; dashed grey, the one with 15 degrees, shifted a little to the right.0.0000.0250.0500.0750.100051015202530354014 S² / 36densitymean 1410,000 values of 14 S²/36χ²(14)χ²(15), without the −1
What hist and the two curve calls draw. The histogram goes with χ²(14), not χ²(15).

How to read it

  • mean_u 14.01 and var_u 28.54: the mean and variance of a χ²(14) are 14 and 28. The simulation nails them.
  • The picture: the histogram fits the χ²(14) (coral). The dashed χ²(15) sits a little to the right: it is the curve you would get if you forgot the “minus one”. With 15 data the difference is small but visible; with 5 data it would be huge.

And the exam question: with 15 pings, what is the probability that the sample variance exceeds 50? And which value b does the sample variance exceed only 5 % of the time?

P(S2>50)=P ⁣(14S236>14⋅5036)=P(U>19.44),U∼χ2(14) P(S^2 > 50) = P\!\left(\frac{14 S^2}{36} > \frac{14 \cdot 50}{36}\right) = P(U > 19.44), \qquad U \sim \chi^2(14)
1 - pchisq(14 * 50 / 36, 14)          # P(S^2 > 50)
b <- 36 * qchisq(0.95, 14) / 14       # P(S^2 > b) = 0.05
round(b, 2)
var(library_)                          # the variance of the 12 library pings

Output:

[1] 0.1486521
[1] 60.9
[1] 52.55364

On 15 % of afternoons the variance of 15 pings will exceed 50, even though the population’s is 36: the sample variance moves much more than the mean. And b=60.90 b = 60.90 : only 5 % of the time does it go beyond that. The library, at 52.55 (and with 12 pings, not 15), does not reach it: nothing suggests its variability is larger than Computer Science’s.

Working out b, without skipping anything

In the paper exam you’ll have the χ² table instead of R. This is how the two numbers above come out:

StepCalculationWhy
1. What you known=15 n = 15 , σ2=36 \sigma^2 = 36 , normal populationWithout a normal population there is no χ²
2. The variable with a nameU=14S2/36∼χ2(14) U = 14 S^2/36 \sim \chi^2(14) It is the only thing about S2 S^2 whose distribution you know
3. Turn the event into US2>50  ⟺  U>14⋅50/36=19.44 S^2 > 50 \iff U > 14 \cdot 50/36 = 19.44 You multiply both sides by 14/36, which is positive: the inequality doesn’t flip
4. The probabilityP(U>19.44)=0.15 P(U > 19.44) = 0.15 With R, 1 – pchisq(19.44, 14); in the table, 19.44 falls between the 0.80 (18.15) and 0.90 (21.06) quantiles, so it is between 0.10 and 0.20
5. For b, the other way roundP(U>14b/36)=0.05⇒14b/36=23.68 P(U > 14b/36) = 0.05 \Rightarrow 14b/36 = 23.68 23.68 is qchisq(0.95, 14), the value that leaves 5 % to the right
6. Solveb=36⋅23.68/14=60.90 b = 36 \cdot 23.68/14 = 60.90 You undo step 3 by multiplying by 36/14 (with the rounded quantile you get 60.89; R gives 60.90)
7. Said in the problem60.90Only on 5 % of afternoons does the variance of 15 pings exceed 60.90, even though the true one is 36
Check you’ve got it: with the 12 library pings, what distribution does 11 S²/36 have, and which value b does the sample variance exceed only 5 % of the time?

A χ²(11): there are 12 pings and the mean is computed from them, so 11 degrees of freedom are left. For b, the same path as in the table: P(S2>b)=P(11S2/36>11b/36)=0.05 P(S^2 > b) = P(11 S^2/36 > 11b/36) = 0.05 , so 11b/36 11b/36 is the 95 % quantile of the χ²(11), qchisq(0.95, 11) = 19.68, and b=36⋅19.68/11=64.41 b = 36 \cdot 19.68/11 = 64.41 . The library’s variance, 52.55, stays below it: the conclusion in the text holds, now with the degrees of freedom that belong to 12 pings. Notice that b has gone up (from 60.90 to 64.41): with less data, the sample variance moves more.

Rearranging wrongly. The calculation always goes the same way: multiply both sides by (n−1)/σ2 (n-1)/\sigma^2 , find the χ²(n − 1) quantile and go back by multiplying by σ2/(n−1) \sigma^2/(n-1) . If you get a b smaller than σ² for a 5 % right tail, you forgot to go back.

Student’s t

Before the formula: what changes when you use S

Before the definition, look at exactly what happens when you swap σ for S. Multiplying and dividing by σ, the mean standardised with S splits into two pieces:

Xˉ−μS/n=Xˉ−μσ/n⋅σS \frac{\bar X – \mu}{S/\sqrt n} = \frac{\bar X – \mu}{\sigma/\sqrt n} \cdot \frac{\sigma}{S}

With the six library pings from the hook, assuming μ=40 \mu = 40 and σ=6 \sigma = 6 :

PieceWith the six pingsWhat distribution it hasWhy
Xˉ−μσ/n \dfrac{\bar X – \mu}{\sigma/\sqrt n} (46.03−40)/(6/6)=2.46 (46.03 – 40)/(6/\sqrt 6) = 2.46 N(0,1) N(0, 1) It is the usual standardised mean, with the true σ
S/σ S/\sigma 8.02/6=1.34 8.02/6 = 1.34 The square root of a χ²(5) divided by 55S2/36∼χ2(5) 5S^2/36 \sim \chi^2(5) , from the previous section; divided by 5 and square-rooted, it gives S/σ S/\sigma
The first divided by the second2.46/1.34=1.84 2.46/1.34 = 1.84 t(5) t(5) It is the hook’s t t , the same 1.84 that R gives further down

So the t is nothing mysterious: it is a standard normal divided by a random number that hovers around 1. If S always matched σ, that number would be exactly 1 and you would have the normal. But S changes from sample to sample (you saw it in the three afternoons), and when it comes out small it inflates the ratio. With six data points, S comes out below half of σ 6 % of the time (S<σ/2 S < \sigma/2 is the same as 5S2/σ2<1.25 5S^2/\sigma^2 < 1.25 , and pchisq(1.25, 5) = 0.06), and in those samples the t t comes out more than twice the Z. Those large values the normal hardly ever gives are the heavy tails of the t. With more data, S sticks close to σ and the t looks more and more like the normal.

To remember the degrees of freedom of the t, look at where S comes from: from n data points, with the mean estimated from them, so it carries the n − 1 of the χ² of the variance. The t inherits the degrees of freedom of its denominator.

Back to the hook. The standardised mean Xˉ−μσ/n \frac{\bar X – \mu}{\sigma/\sqrt n} is an N(0, 1), but it needs σ. You almost never know it: you replace it with S, your sample’s. And then it is no longer normal. A variable follows a Student’s t with n degrees of freedom, t(n) t(n) , if it can be written as

T=ZY/n,Z∼N(0,1), Y∼χ2(n) independent T = \frac{Z}{\sqrt{Y/n}}, \qquad Z \sim N(0,1),\ Y \sim \chi^2(n) \ \text{independent}

Its density is symmetric about 0, bell-shaped but with heavier tails than the normal:

f(t)=Γ ⁣(n+12)Γ ⁣(n2)nπ(1+t2n)−n+12,−∞<t<∞ f(t) = \frac{\Gamma\!\left(\frac{n+1}{2}\right)}{\Gamma\!\left(\frac n2\right)\sqrt{n\pi}} \left(1 + \frac{t^2}{n}\right)^{-\frac{n+1}{2}}, \qquad -\infty < t < \infty
PropertyFormula
MeanE(T)=0 E(T) = 0 , if n>1 n > 1
VarianceVar⁡(T)=nn−2 \operatorname{Var}(T) = \dfrac{n}{n-2} , if n>2 n > 2
MomentsE(Tr) E(T^r) exists only if r<n r < n
Case n = 1the Cauchy distribution: it has no mean
Large nt(n)→N(0,1) t(n) \to N(0, 1)

And the result that uses all of it: if the sample comes from a normal,

Xˉ−μS/n=n Xˉ−μS∼t(n−1) \frac{\bar X – \mu}{S/\sqrt n} = \sqrt n\, \frac{\bar X – \mu}{S} \sim t(n – 1)

It comes from putting the two previous pieces together: the numerator standardised with σ is an N(0, 1), (n−1)S2/σ2 (n-1)S^2/\sigma^2 is a χ²(n − 1) independent of Xˉ \bar X , and dividing one by the root of the other (over its degrees of freedom) cancels σ. That is why it is useful: you don’t need to know it.

qnorm(0.975)                                  # the usual 1.96
round(qt(0.975, c(2, 5, 14, 30, 100)), 3)     # the t's "1.96", by degrees of freedom
curve(dnorm(x), -4, 4, lty = 2, ylab = "f(x)")
for (k in c(1, 5, 14)) curve(dt(x, k), add = TRUE)

Output:

[1] 1.959964
[1] 4.303 2.571 2.145 2.042 1.984
Student's t against the normalStudent's t densities with 1, 5 and 14 degrees of freedom between −4 and 4, and the standard normal in dashed grey. All are symmetric bells at 0; t(1), the Cauchy, is the lowest in the center and the heaviest in the tails; t(5) and t(14) get closer and closer to the normal.0.00.10.20.30.4−4−3−2−101234xf(x)t(1)t(5)t(14)heavier tailsN(0, 1)t(1), Cauchy
What curve(dnorm) and the curve calls with dt draw. With 14 degrees of freedom the t almost covers the normal.

How to read it

  • 1.959964 against 4.303, 2.571, 2.145, 2.042, 1.984: the value that leaves 2.5 % in each tail. With the normal it is 1.96; with the t it is larger, much larger with few degrees of freedom. With 5 degrees (6 data, the hook) you have to go out to 2.57; with 100 degrees, 1.98, almost the normal.
  • The picture: t(1) (Cauchy) is the lowest in the center and the heaviest in the tails; t(5) and t(14) get closer to the dashed normal. Heavy tails are the price of not knowing σ: S varies too, and sometimes comes out small and inflates the ratio.

With that, the hook done properly. Six pings in the library, mean 46.03 and standard deviation 8.02. If the true mean were 40, what is the probability of a mean like that or higher?

six <- library_[1:6]
t_obs <- (mean(six) - 40) / (sd(six) / sqrt(6))
round(c(mean = mean(six), s = sd(six), t_obs = t_obs), 2)
1 - pnorm(t_obs)          # what I did: as if it were N(0, 1)
1 - pt(t_obs, df = 5)     # the right one: t with n - 1 = 5 degrees of freedom

Output:

 mean     s t_obs 
46.03  8.02  1.84 
[1] 0.03260387
[1] 0.06226627

With the normal, 3.3 %; with the t, 6.2 %, almost double. With six data, the difference between knowing σ and estimating it is huge. With the 12 library pings the calculation is different (you do it in the exercises), but the lesson stays: if the standard deviation comes from the sample, the table is the t.

Using pnorm or qnorm with S. With small n you are genuinely wrong (3 % against 6 %); with large n it hardly shows, which is why the mistake goes unnoticed in practice sessions with lots of data and turns up in the exam with 6.

Snedecor’s F

Before the formula: dividing two variances

How do you compare the variability of two buildings? Subtracting variances doesn’t work: 52.55 − 38.29 = 14.26, and without knowing the scale you can’t tell whether that is a lot or a little. You divide them. And to know which ratio is normal, each variance is first put on its own scale, dividing it by its σ²:

PieceWith the wifiWhat it isWhy
S12/σ12 S_1^2/\sigma_1^2 38.29/36 = 1.06A χ²(14) divided by 1414S12/36∼χ2(14) 14 S_1^2/36 \sim \chi^2(14) ; dividing by 14 leaves S12/36 S_1^2/36
S22/σ22 S_2^2/\sigma_2^2 52.55/36 = 1.46A χ²(11) divided by 1112 pings, 11 degrees of freedom
The first divided by the second1.06/1.46 = 0.73F(14,11) F(14, 11) A χ² over its degrees of freedom, divided by another one like it, independent

Each piece has mean 1: a χ²(k) has mean k and you have divided it by k. So, if the two σ are equal, the ratio hovers around 1. But each piece jumps around (remember the variances of the three afternoons, from 25 to 67), and the ratio jumps around even more, especially upwards: if the denominator comes out small, the ratio shoots up; if it comes out large, the ratio can only go down to 0. That is why the F is positive and skewed to the right.

The degrees of freedom go in order, first the top ones and then the bottom ones, because dividing 1.06 by 1.46 is not the same as the other way round. And if the two σ are equal, they cancel and you are left with just S12/S22 S_1^2/S_2^2 , which you compute from the data: 38.29/52.55 = 0.73. Now, the definition:

To compare the variability of two buildings you need a ratio of variances. If U∼χ2(m) U \sim \chi^2(m) and V∼χ2(n) V \sim \chi^2(n) are independent,

F=U/mV/n∼F(m,n) F = \frac{U/m}{V/n} \sim F(m, n)

follows a Snedecor F with (m, n) degrees of freedom: m for the numerator, n for the denominator, in that order. It is positive and skewed, and satisfies:

PropertyFormula
MeanE(F)=nn−2 E(F) = \dfrac{n}{n-2} , if n>2 n > 2 (close to 1)
ReciprocalF∼F(m,n)⇒1/F∼F(n,m) F \sim F(m, n) \Rightarrow 1/F \sim F(n, m)
Link with the tT∼t(n)⇒T2∼F(1,n) T \sim t(n) \Rightarrow T^2 \sim F(1, n)

And the result for two independent normal samples, of sizes m and n:

S12/σ12S22/σ22∼F(m−1, n−1),and if σ1=σ2:S12S22∼F(m−1, n−1) \frac{S_1^2/\sigma_1^2}{S_2^2/\sigma_2^2} \sim F(m – 1,\ n – 1), \qquad \text{and if } \sigma_1 = \sigma_2: \quad \frac{S_1^2}{S_2^2} \sim F(m – 1,\ n – 1)

With the wifi: Computer Science (15 pings) in the numerator and the library (12) in the denominator. If both have σ = 6, S12/S22∼F(14,11) S_1^2/S_2^2 \sim F(14, 11) . Between which two values does that ratio fall 90 % of the time?

a <- qf(0.05, 14, 11); b <- qf(0.95, 14, 11)
round(c(a = a, b = b), 3)
round(var(compsci) / var(library_), 3)              # the ratio of our samples
round(c(qf(0.05, 14, 11), 1 / qf(0.95, 11, 14)), 4) # the reciprocal property
curve(df(x, 14, 11), 0, 5, ylab = "f(x)")

Output:

    a     b 
0.390 2.739 
[1] 0.729
[1] 0.3898 0.3898
F(14, 11): where the ratio fallsDensity of the Snedecor F with 14 and 11 degrees of freedom between 0 and 5, skewed to the right. Shaded in coral, the two 5 % tails, left of 0.390 and right of 2.739; the 90 % lies between them. In green, the ratio of the variances of our samples, 0.729, inside the central zone.0.00.20.40.60.80.00.51.01.52.02.53.03.54.04.55.0xf(x)a = 0.390b = 2.7395 %5 %ours: 0.72990 %
What curve(df(x, 14, 11)) draws, with the qf quantiles. The two tails are not symmetric around 1.

How to read it

  • a = 0.390 and b = 2.739: 90 % of the time, the ratio of the variances of 15 and 12 pings falls between 0.39 and 2.74, even if the two populations have exactly the same variance. Notice the interval is not symmetric about 1: the F is skewed to the right.
  • 0.729: our ratio, 38.29 / 52.55. It is inside: the samples don’t say one building is more variable than the other.
  • 0.3898 twice: the 5 % quantile of F(14, 11) is the reciprocal of the 95 % quantile of F(11, 14). That is the reciprocal property: before R, tables only had the right tail, and this is how you got the left one.
  • The picture: the F(14, 11) density with the two 5 % tails shaded and our 0.73 marked in the middle.

Swapping the order of the degrees of freedom. qf(0.95, 11, 14) is not qf(0.95, 14, 11) (2.57 against 2.74). The first is always that of the sample on top, minus 1.

Check you’ve got it: if you put the library on top, what distribution does the ratio have, and between which two values does it fall 90 % of the time?

With 12 pings on top and 15 below, S22/S12∼F(11,14) S_2^2/S_1^2 \sim F(11, 14) : first the degrees of the sample on top, 12 − 1, then those of the one below, 15 − 1. The limits are qf(0.05, 11, 14) = 0.37 and qf(0.95, 11, 14) = 2.57. You don’t even need R: by the inverse property, they are 1/2.74 and 1/0.39, the earlier ones turned upside down. The ratio, 52.55/38.29 = 1.37, is also the earlier one upside down (1/0.73) and it is still inside. The conclusion doesn’t change when you change the order; what changes are the numbers, and that is why the degrees of freedom have to go in the order of the fraction you have written.

Two samples: the difference of means

Last piece. Is the library slower than Computer Science? The natural thing is to look at Yˉ−Xˉ \bar Y – \bar X . If the two samples are normal and independent,

Xˉ−Yˉ∼N ⁣(μ1−μ2, σ12m+σ22n) \bar X – \bar Y \sim N\!\left(\mu_1 – \mu_2,\ \sqrt{\frac{\sigma_1^2}{m} + \frac{\sigma_2^2}{n}}\right)

(the variances add even though the means subtract). If the standard deviations are equal but unknown, the common one is estimated by pooling the two samples (the pooled variance) and you get another t, now with m+n−2 m + n – 2 degrees of freedom:

Sp2=(m−1)S12+(n−1)S22m+n−2,T=(Xˉ−Yˉ)−(μ1−μ2)Sp1m+1n∼t(m+n−2) S_p^2 = \frac{(m-1)S_1^2 + (n-1)S_2^2}{m + n – 2}, \qquad T = \frac{(\bar X – \bar Y) – (\mu_1 – \mu_2)}{S_p\sqrt{\frac1m + \frac1n}} \sim t(m + n – 2)

It is the same formula as in the course notes, mn(m+n−2)m+n (Xˉ−Yˉ)−(μ1−μ2)(m−1)S12+(n−1)S22 \sqrt{\frac{mn(m+n-2)}{m+n}}\, \frac{(\bar X – \bar Y) – (\mu_1 – \mu_2)}{\sqrt{(m-1)S_1^2 + (n-1)S_2^2}} , with the terms arranged differently.

m <- length(compsci); n <- length(library_)
sp2 <- ((m - 1) * var(compsci) + (n - 1) * var(library_)) / (m + n - 2)
t_obs <- (mean(compsci) - mean(library_)) / sqrt(sp2 * (1 / m + 1 / n))
round(c(sp = sqrt(sp2), t_obs = t_obs, df = m + n - 2), 3)
pt(t_obs, m + n - 2)           # P(T <= t_obs) if the two means were equal

Output:

    sp  t_obs     df 
 6.676 -2.121 25.000 
[1] 0.02201559

The pooled standard deviation is 6.68 ms (between 6.19 and 7.25, closer to the larger sample’s). If the two buildings had the same mean, a t t of −2.12 or lower would only come up 2.2 % of the time: the library does look slower.

With paired data (the same 10 spots on campus measured in the morning and the afternoon) the samples are not independent and this formula does not apply. You subtract pair by pair, Di=Xi−Yi D_i = X_i – Y_i , and use the one-sample t on the differences: n (Dˉ−μD)/SD∼t(n−1) \sqrt n\, (\bar D – \mu_D)/S_D \sim t(n-1) . It comes up in the exam: we prove it in the topic’s proofs.

Which distribution do I use?

I want to talk about…StatisticDistributionIn R
The mean, σ knownXˉ−μσ/n \dfrac{\bar X – \mu}{\sigma/\sqrt n} N(0, 1)pnorm, qnorm
The mean, σ estimated by SXˉ−μS/n \dfrac{\bar X – \mu}{S/\sqrt n} t(n − 1)pt, qt
The variance(n−1)S2σ2 \dfrac{(n-1)S^2}{\sigma^2} χ²(n − 1)pchisq, qchisq
Squares with μ and σ known∑(Xi−μσ)2 \sum \left(\frac{X_i – \mu}{\sigma}\right)^2 χ²(n)pchisq, qchisq
Two variancesS12/σ12S22/σ22 \dfrac{S_1^2/\sigma_1^2}{S_2^2/\sigma_2^2} F(m − 1, n − 1)pf, qf
Two means, σ known(Xˉ−Yˉ)−(μ1−μ2)σ12/m+σ22/n \dfrac{(\bar X – \bar Y) – (\mu_1 – \mu_2)}{\sqrt{\sigma_1^2/m + \sigma_2^2/n}} N(0, 1)pnorm
Two means, equal unknown σ(Xˉ−Yˉ)−(μ1−μ2)Sp1/m+1/n \dfrac{(\bar X – \bar Y) – (\mu_1 – \mu_2)}{S_p\sqrt{1/m + 1/n}} t(m + n − 2)pt, qt
Paired dataDˉ−μDSD/n \dfrac{\bar D – \mu_D}{S_D/\sqrt n} t(n − 1)pt, qt

Everything needs the population to be normal. If it is not and n is large, the mean is still almost normal by the CLT; the χ² and the F for variances, on the other hand, do not fix themselves.

The family tree: everything comes from the normalDiagram. Two arrows leave the standard normal Z: squared it gives a chi-square with 1 degree, and adding n independent squares, a chi-square with n. A normal divided by the root of a chi-square over its degrees of freedom gives Student's t. A ratio of two independent chi-squares, each over its degrees, gives F. The t squared is an F with 1 and n degrees.Z ~ N(0, 1)the originZ² ~ χ²(1)squaredΣ Zᵢ² ~ χ²(n)n squares addedZ / √(Y/n)t(n), with Y ~ χ²(n)(U/m) / (V/n)F(m, n): two χ²two χ²independentin the denominatort² ~ F(1, n)if n is large,t(n) goes back to N(0, 1)
The three distributions of the topic are standard normals combined in three ways.

The picture puts the family tree together: everything is born from the N(0, 1). Squared and added it gives the χ²; a normal over the root of a χ² gives the t; a ratio of χ²s gives the F. And the t squared is an F with 1 degree on top.

In R: what you need

I want…In R
Density, cumulative probability, quantile and simulation of χ²(k)dchisq(x, k), pchisq(x, k), qchisq(p, k), rchisq(m, k)
The same for t(k)dt(x, k), pt(x, k), qt(p, k), rt(m, k)
The same for F(k1, k2)df(x, k1, k2), pf(x, k1, k2), qf(p, k1, k2), rf(m, k1, k2)
A right tail1 - pchisq(x, k) or pchisq(x, k, lower.tail = FALSE)
The sample variance (with n − 1)var(x)
The standard error of the meansd(x) / sqrt(length(x))
Simulate a statistic’s distributionreplicate(10000, statistic(rnorm(n, mu, sigma)))

Reading qchisq, qt and qf without slipping up

The four letters work the same way in all three distributions: p goes from a value to a probability, that of falling to the left, and q goes from a probability to a value, the one that leaves that probability to the left. Almost every mistake is about the tail. The safe way: sketch the density, shade what you are asked for and ask yourself how much is left to the left of the value you are looking for. That number is the first argument of q.

You’re asked for…Area to the leftCallResultWhy
The value the χ²(14) exceeds only 5 % of the time0.95qchisq(0.95, 14)23.68If 5 % is left to the right, 95 % is left to the left
The two values that leave 2.5 % in each tail of the χ²(14)0.025 and 0.975qchisq(c(0.025, 0.975), 14)5.63 and 26.12The χ² is not symmetric: 26.12 is not as far from 14 as 5.63, so you need both
The “1.96” of the t with 5 degrees of freedom0.975qt(0.975, 5)2.572.5 % above; the lower one is −2.57 by symmetry
The value the t(14) exceeds 5 % of the time0.95qt(0.95, 14)1.76It is a single tail: the 5 % is not split
The limits of the central 90 % of the F(14, 11)0.05 and 0.95qf(c(0.05, 0.95), 14, 11)0.39 and 2.74Skewed, like the χ²: two calls

Writing qt(0.05, 14) when you’re asked for the value exceeded 5 % of the time. It gives −1.76, the one for the left tail. If you get a negative quantile for a right tail, or a χ² quantile below its degrees of freedom when you’re looking for the right tail, you’ve put the area on the right where the area on the left should go.

Check you’ve got it: with the six pings from the hook, which value c satisfies P(T > c) = 0.05, and what does it tell you about the 1.84?

With six pings, T∼t(5) T \sim t(5) . To the right of c there is 5 %, so to the left there is 95 %: c = qt(0.95, 5) = 2.02. The hook’s t t , 1.84, stays below it: it doesn’t reach the most extreme 5 %, and that is why the probability of a mean like that or higher came out at 6.2 %, a bit more than 5 %. With the normal, the limit would have been qnorm(0.95) = 1.64, and 1.84 does pass it: it is the same wrong conclusion as in the hook, now told with quantiles.

What gets proved in this topic

All of them, step by step and checked with R, in the sampling distributions proofs:

  1. E(Xˉ)=μ E(\bar X) = \mu and Var⁡(Xˉ)=σ2/n \operatorname{Var}(\bar X) = \sigma^2/n .
  2. E(S2)=σ2 E(S^2) = \sigma^2 : why you divide by n−1 n – 1 .
  3. The mean of normals is normal, with the moment generating function.
  4. The chi-square is a gamma: its mgf, its mean and its variance.
  5. Z2∼χ2(1) Z^2 \sim \chi^2(1) and the sum of independent chi-squares.
  6. (n−1)S2/σ2∼χ2(n−1) (n-1)S^2/\sigma^2 \sim \chi^2(n-1) , with the decomposition of the sum of squares.
  7. n(Xˉ−μ)/S∼t(n−1) \sqrt n (\bar X – \mu)/S \sim t(n-1) .
  8. The F for two variances, the reciprocal of an F and T2∼F(1,n) T^2 \sim F(1, n) .
  9. The two-sample t with common variance and the paired t.

Common mistakes

  • Dividing the sample variance by n. var() already divides by n−1 n – 1 ; if you compute it by hand, so do you. With n in the denominator, (n−1)S2/σ2 (n-1)S^2/\sigma^2 stops being a χ²(n − 1).
  • Using n degrees of freedom instead of n − 1. In (n−1)S2/σ2 (n-1)S^2/\sigma^2 and in the one-sample t they are n−1 n – 1 ; in the two-sample t, m+n−2 m + n – 2 ; in the F, m−1 m – 1 and n−1 n – 1 . Only the sum of squares with known μ has n.
  • Using the normal with S. If σ comes from the data, it is a t. The normal only if σ is the population’s.
  • Thinking the t or the χ² are symmetric like the normal. The t is (q0.025=−q0.975 q_{0.025} = -q_{0.975} ); the χ² and the F are not: their two quantiles are computed separately.
  • Forgetting the normality condition. The exact distributions of this topic need samples from a normal. For the mean with large n the CLT applies; for the variance, it does not.
  • Subtracting the variances in a difference of means. Var⁡(Xˉ−Yˉ)=σ12/m+σ22/n \operatorname{Var}(\bar X – \bar Y) = \sigma_1^2/m + \sigma_2^2/n : they add.

Try it in the R playground

Open the R playground on the site (or RStudio) and paste this script. It puts the topic’s four distributions together with the wifi:

set.seed(2026)
pings <- function(n) rnorm(n, 40, 6)          # n Computer Science pings
# 1. The mean of 15 pings: normal with sd 6/sqrt(15)
means <- replicate(10000, mean(pings(15)))
c(sd_simulated = sd(means), sd_theoretical = 6 / sqrt(15))
# 2. The variance: 14 S^2 / 36 is a chi^2(14)
u <- replicate(10000, 14 * var(pings(15)) / 36)
hist(u, freq = FALSE, breaks = 40); curve(dchisq(x, 14), add = TRUE, lwd = 2)
# 3. The mean standardised with S: t(5) with 6 pings, not N(0, 1)
tt <- replicate(10000, { x <- pings(6); (mean(x) - 40) / (sd(x) / sqrt(6)) })
c(outside_196 = mean(abs(tt) > 1.96), outside_qt = mean(abs(tt) > qt(0.975, 5)))
# 4. The ratio of variances of 15 and 12 pings: F(14, 11)
ff <- replicate(10000, var(pings(15)) / var(pings(12)))
mean(ff > qf(0.95, 14, 11))

Things to look at:

  1. That the simulated standard deviation of the means comes out close to 1.549.
  2. That the histogram of u fits the χ²(14) drawn on top.
  3. That with 6 pings, more than 5 % of the means standardised with S fall outside ±1.96 (around 10 %), and with the t quantile it comes out close to 5 %.
  4. That the ratio of variances exceeds the 95 % quantile of F(14, 11) 5 % of the time.

Summary

Statistic (normal population)Distribution
Xˉ \bar X N(μ,σ/n) N(\mu, \sigma/\sqrt n)
∑i(Xi−μσ)2 \sum_{i}\left(\frac{X_i – \mu}{\sigma}\right)^2 χ2(n) \chi^2(n)
(n−1)S2/σ2 (n-1)S^2/\sigma^2 χ2(n−1) \chi^2(n-1) , independent of Xˉ \bar X
n(Xˉ−μ)/S \sqrt n(\bar X – \mu)/S t(n−1) t(n-1)
S12/σ12S22/σ22 \dfrac{S_1^2/\sigma_1^2}{S_2^2/\sigma_2^2} F(m−1,n−1) F(m-1, n-1)
(Xˉ−Yˉ)−(μ1−μ2)Sp1/m+1/n \dfrac{(\bar X – \bar Y) – (\mu_1 – \mu_2)}{S_p\sqrt{1/m + 1/n}} t(m+n−2) t(m+n-2)
χ²(n)gamma(n/2, 1/2): mean n, variance 2n
t(n)symmetric, mean 0, variance n/(n − 2), tends to N(0, 1)
F(m, n)positive; 1/F ~ F(n, m); t(n)² ~ F(1, n)

Three ideas to take away:

  1. A statistic is a random variable. Each sample gives a value; the sampling distribution says how much it moves. The mean moves with σ/n \sigma/\sqrt n ; the variance, much more.
  2. Degrees of freedom count what is left free. Every parameter you estimate from the data (μ with Xˉ \bar X ) eats one: n−1 n – 1 for S2 S^2 , m+n−2 m + n – 2 for two samples.
  3. If you estimate σ, the normal becomes a t. With few data the difference is large; with many, the t blends into the normal.

Now it’s time to do it on the computer: in the sampling distributions practice in R you draw the three families, simulate means and variances of thousands of ping samples and check the F and the t for two buildings. And to check you have got it, the sampling distributions exercises have chained exam-style exercises with commented solutions.

Next step: proofsSampling distributions — step-by-step proofs with the campus wifi, the mgf and the degrees of freedom you lose (and the μ that sneaked into my mock exam)

Did this article help you? Here is how you can support SergioLearns →