Sampling 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)
In a class mock exam I was asked to prove that is a chi-square and I did it in three lines. I wrote: “each is a standard normal, there are n of them, so the sum of their squares is a “. The lecturer circled the and wrote in the margin: “is this μ?”. It is not. Deviations from the sample mean are not independent standard normals: they always add up to 0, and that is why one degree of freedom is lost. Since then, before adding squares of normals, I check what they are centred on.
Here, step by step, are the proofs of the sampling distributions topic: the sample mean and variance, the chi-square family, the one-sample t, the F and the two-sample t. In the theory you saw what they say and how they are used with the campus wifi; here, why they are true. Each one ends with the result as it goes on the cheat sheet (in the exam you can only bring results, not proofs) and with a check in R.
Table of Contents
Before you start: the rules we will use
All of them come from earlier topics. We number them to cite them at each step (“by rule 4”).
| Rule | What it says | Where it is used |
|---|---|---|
| 1. Linearity of expectation | , no independence needed | Proofs 1, 2 and 9 |
| 2. Variance of a sum of independent variables | Proofs 1 and 9 | |
| 3. Shortcut variance | Proof 2 | |
| 4. mgf of a sum of independent variables | Proofs 3, 4, 5 and 6 | |
| 5. mgf of | Proof 3 | |
| 6. Uniqueness | two variables with the same mgf (near 0) have the same distribution | Proofs 3 to 6 |
| 7. Known mgfs | normal: ; gamma(a, b): | Proofs 3, 4 and 5 |
| 8. Gaussian integral | Proof 5 | |
| 9. Functions of independent variables | if X and Y are independent, so are and | Proofs 6, 7 and 9 |
| 10. Independence of and | in an SRS from a normal, and are independent | Proofs 6, 7 and 9 |
Rule 10 is proved with the joint mgf, but the calculation is long and the course notes take it as given: so do we.
Proof 1: the sample mean points at μ and concentrates with n
What we want to prove
If is an SRS from a population with mean μ and variance σ² (of any shape, it need not be normal):
Why it matters. hits μ on average and moves less the larger n is. With σ = 6, its standard deviation is 1.55 ms with 15 pings and 0.77 with 60: four times the sample, half the error.
What we start from
with and for each i, and the independent.
Step 1: the expectation
By rule 1, with :
Step 2: the variance
By rule 2, which does need independence, with :
The constant comes out squared, but the sum of n equal variances gives back an n: you are left with , and the standard deviation, .
Writing (forgetting that n variances are added) or (forgetting the square of ). Check with n = 1: you must get σ².
Result for the cheat sheet. , , .
Check it with R
With the wifi, 10,000 means of n pings for three sizes. If the proof is right, must always come out close to 36:
set.seed(2026)
for (n in c(5, 15, 60)) {
means <- replicate(10000, mean(rnorm(n, 40, 6)))
cat("n =", n, " mean:", round(mean(means), 2), " n * var:", round(n * var(means), 2), "\n")
}
Output:
n = 5 mean: 40.02 n * var: 36.99 n = 15 mean: 40.01 n * var: 35.74 n = 60 mean: 40 n * var: 36.01
The mean of the means is always at 40 and around 36, for all three sizes. If the variance were , the second column would drop as n grows.
Check you’ve got it: if the pings were measured back to back and were not independent, which part of the proof would still hold?
The expectation does: rule 1 does not ask for independence, so still stands. The variance does not: rule 2 only holds for independent variables. With dependent pings, covariances appear and is no longer .
Proof 2: why S² divides by n − 1
What we want to prove
With the same assumptions (any population with mean μ and variance σ²):
Why it matters. It explains why R’s var() divides by n − 1. And is the variance of proofs 6 to 9: if it fell short on average, every t and F in the topic would come out skewed.
What we start from
From proof 1 and rule 3 applied to each and to :
Step 1: expand the sum of squares
Open the square and use :
What gets skipped: is the definition of the mean, and the last term is because does not depend on i and is added n times.
Step 2: take expectations
By rule 1 (no independence needed) and the two expectations we started from:
The terms go. What is left is , not : there is the lost degree of freedom.
Why each piece: is n equal expectations, and the n in comes out of the expectation because it is a constant. The two pieces only differ in the variance: σ² versus .
Step 3: divide
If you had divided by n, the expectation would be : always below.
The picture explains step 2 without any algebra: with the 15 Computer Science pings, the sum of squares about is smaller than about any other number, including μ = 40. Measuring from the center of the sample itself always falls short, and dividing by compensates exactly.
Thinking the is for “small samples”. It holds for any n: with n = 1000 the difference is small, but dividing by n is still biased.
Result for the cheat sheet. for any population; .
Check it with R
The proof does not use normality, so we check it with exponential pings (a very skewed population) with mean 40, whose variance is :
set.seed(2026) s2 <- replicate(20000, var(rexp(5, 1 / 40))) # var() divides by n - 1 round(c(sigma2 = 1600, with_n1 = mean(s2), with_n = mean(s2 * 4 / 5)), 1) x <- 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) c(sum((x - mean(x))^2), sum(x^2) - length(x) * mean(x)^2) # step 1, with numbers
Output:
sigma2 with_n1 with_n 1600.0 1591.7 1273.4 [1] 536.0133 536.0133
With , the mean of 20,000 variances comes out close to 1600; with n, close to . And the two forms of the sum of squares in step 1 agree with the 15 Computer Science pings.
Check you’ve got it: with the 15 Computer Science pings, the sum of squares about the mean is 536.01. What is the variance dividing by 14 and by 15, and which one is unbiased?
By 14: ; by 15: . The unbiased one is , but that shows on average over many afternoons, not in one: with σ² = 36, the n − 1 version averages 36 and the n version, .
Proof 3: the mean of normals is normal
What we want to prove
If are independent with and are constants:
and, in particular, for an SRS from an : and .
Why it matters. Proof 1 gives the mean and variance of , not its shape. To compute probabilities you need to know it is normal: with 15 pings, .
What we start from
The mgf of each (rule 7): .
Step 1: the mgf of Y as a product
By rule 4 (independence) and rule 5 (each term is ):
What gets skipped in the last equality: in the normal’s mgf, t is replaced by . Since t is squared in the second term, you get : that square ends up in the variance.
Step 2: combine the exponents
A product of exponentials is the exponential of the sum:
Step 3: recognise the mgf
It is the mgf of a normal with mean and variance . By rule 6, Y is that normal.
Step 4: the two special cases
With , , : mean , variance . With : mean μ, variance .
Subtracting variances when subtracting variables. With , : . The difference of two sample means has more variance than either.
Result for the cheat sheet. with independent normals; ; .
Check it with R
The difference between the mean of 12 library pings, , and that of 15 Computer Science pings, , should be :
set.seed(2026) dif <- replicate(10000, mean(rnorm(12, 46, 6)) - mean(rnorm(15, 40, 6))) round(c(mean = mean(dif), sd = sd(dif), sd_theoretical = sqrt(36 / 12 + 36 / 15)), 3) c(simulated = mean(dif > 10), normal = 1 - pnorm(10, 6, sqrt(36 / 12 + 36 / 15)))
Output:
mean sd sd_theoretical
5.991 2.327 2.324
simulated normal
0.04190000 0.04259585
The mean of the differences is 6, the standard deviation matches the theoretical one, and the probability that the library is more than 10 ms behind Computer Science, simulated and with the normal, is practically the same.
Check you’ve got it: if the library wifi had σ = 8 instead of 6, what distribution would the difference between its mean and the Computer Science one have?
The mean does not change: 46 − 40 = 6. The variances add up (): . So it is an , wider than the above.
Proof 4: the chi-square is a gamma
What we want to prove
That and, from there, its mgf, its mean and its variance:
Why it matters. It links the chi-square with the gamma from topic 4 and inherits its mgf without integrating anything. That mgf, , is the tool of proofs 5 and 6.
What we start from
The density of the and that of a gamma(a, b) from topic 4:
Step 1: compare the densities
With and , the gamma density is, letter for letter, the one. They are the same distribution.
Step 2: the mgf
By rule 7, the mgf of the gamma(a, b) is . With , :
Step 3: the mean, by differentiating
Why differentiate: the derivative of the mgf at 0 is . At , any power of is 1 and only the number in front is left. The is the chain rule.
Step 4: the variance, differentiating again
It also comes out with the gamma formulas: and .
Forgetting the chain rule when differentiating : the inner goes missing and you get . A chi-square is positive: its mean cannot be negative.
Result for the cheat sheet. ; ; ; .
Check it with R
k <- 7 f <- function(x) dchisq(x, k) g <- function(x) dgamma(x, shape = k / 2, rate = 1 / 2) c(same = all.equal(f(1:20), g(1:20))) # the two densities coincide m1 <- integrate(function(x) x * f(x), 0, Inf)$value m2 <- integrate(function(x) x^2 * f(x), 0, Inf)$value round(c(mean = m1, var = m2 - m1^2), 4) # n = 7 and 2n = 14
Output:
same TRUE mean var 7 14
all.equal says the densities of and gamma(3.5, 0.5) are equal at the 20 points, and the integrals give mean 7 and variance 14.
Check you’ve got it: the chi-square with 14 degrees from the 15 Computer Science pings: what mean, variance and mgf does it have, and which gamma is it?
Mean 14, variance (standard deviation 5.29) and mgf for . It is a gamma(7, 0.5): and , the same.
Proof 5: Z² is a χ²(1) and chi-squares add up
What we want to prove
Two results that, together, give the definition “sum of squared normals”:
and, as a consequence, for an SRS from an .
Why it matters. It says where the chi-square comes from: adding squared standard normals. Proof 6 needs it, and the fact that chi-squares add up is what joins the two samples in proof 9.
Step 1: the mgf of Z²
By the definition of the mgf, integrating against the density of Z:
The last equality just joins exponents: , taking as a common factor.
Step 2: recognise a Gaussian integral
For , write with . By rule 8, the integral is :
It is the mgf of proof 4 with n = 1. By rule 6, .
Why : if , the exponential does not go down to 0 and the integral does not converge. It does no harm: the mgf is only needed near 0. And the root at the bottom is .
Step 3: the sum of independent chi-squares
By rule 4, the mgf of the sum is the product:
which is the mgf of a .
Step 4: the sum of squares with μ and σ
Each is an N(0, 1); they are independent because each is a function of a single (rule 9). By step 2, each , and by step 3 the sum of the n of them is a .
Applying step 4 with instead of μ. The are not independent (they add up to 0): that case is proof 6, and it gives degrees.
Result for the cheat sheet. ; if independent; .
Check it with R
With μ = 40 and σ = 6 known, the sum of the 15 standardised squares of an afternoon of pings must be a : the simulated 95 % quantile must come out close to qchisq(0.95, 15).
set.seed(2026)
total <- replicate(10000, sum(((rnorm(15, 40, 6) - 40) / 6)^2))
round(c(mean = mean(total), var = var(total), q95 = unname(quantile(total, 0.95)),
q95_theoretical = qchisq(0.95, 15)), 2)
Output:
mean var q95 q95_theoretical
15.05 30.42 24.96 25.00
Mean close to 15 and variance close to 30 ( and ), and the simulated 95 % quantile next to the theoretical one, 25.00.
Check you’ve got it: if the 15 pings were standardised with 38 instead of the true μ = 40, would the sum of the squares still be a chi-square with 15 degrees?
No. Each has mean , not 0: it is no longer an N(0, 1). By rule 3, each square has expectation , and the sum, instead of 15. That is why the true μ is needed.
Proof 6: (n − 1)S²/σ² is a χ²(n − 1)
What we want to prove
If is an SRS from an :
Why it matters. It is the hook’s proof. With real data μ is unknown and you center on : this says what happens then. It is the basis of intervals for σ² and the bottom piece of the t and the F.
What we start from
From proof 5 (with known μ, n degrees) and rule 10 ( and independent).
Step 1: add and subtract
Inside each square of the sum with μ, add and subtract :
Step 2: expand and drop the cross term
Expanding gives three sums. The middle one is , and deviations from the mean always add up to 0: . What is left:
In the other two sums: the first stays as it is, and in the third does not depend on i, so it is added n times.
Step 3: divide by σ² and name each piece
We call each piece:
What we know: by proof 5; by proof 3, so ; and Y and V are independent because Y depends only on and V only on (rules 9 and 10).
Step 4: solve for the mgf of Y
By rule 4, :
It is the mgf of a . By rule 6, .
Why you can solve for it: is never 0, and subtracting exponents gives . Without the independence of Y and V (rule 10), the mgf of W would not be the product.
In the picture, the decomposition of step 2 with the 15 Computer Science pings: the sum of squares about μ (577.68) splits into the one about (536.01) plus (41.67). The second piece is the degree of freedom the mean takes.
Saying “they are n squares of normals, so it is a “. That is the hook’s mistake. What has n degrees is W, with μ; with one is lost, the one V keeps.
Result for the cheat sheet. , independent of . Hence and .
Check it with R
First the decomposition with the data (it is an identity: it must come out exact) and then the distribution by simulation:
x <- 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)
n <- length(x); mu <- 40
round(c(with_mu = sum((x - mu)^2), with_mean = sum((x - mean(x))^2),
mean_piece = n * (mean(x) - mu)^2), 2)
set.seed(2026)
y <- replicate(10000, 14 * var(rnorm(15, 40, 6)) / 36)
round(c(q05 = unname(quantile(y, 0.05)), theoretical_14 = qchisq(0.05, 14), with_15 = qchisq(0.05, 15)), 2)
Output:
with_mu with_mean mean_piece
577.68 536.01 41.67
q05 theoretical_14 with_15
6.56 6.57 7.26
, exactly the sum with μ. And the simulated 5 % quantile of sits next to the one, not the one.
Check you’ve got it: with the 15 Computer Science pings and σ = 6, what is (n − 1)S²/σ², and is it an unusual value for its distribution?
. It is a , with mean 14 and standard deviation 5.29: 14.89 falls almost in the center, . Unusual would be below 6.57 or above 23.68, its 5 % and 95 % quantiles.
Proof 7: the one-sample t
What we want to prove
If is an SRS from an :
Why it matters. You almost never know σ. The standardised normal needs it; the t swaps it for S. This says what the swap costs: degrees and wider tails (2.57 instead of 1.96 with six pings).
What we start from
The definition of the t: if , and they are independent. And two pieces already proved:
Z depends only on and Y only on : by rules 9 and 10, they are independent.
Step 1: build the ratio from the definition
With :
Why Y is divided by its degrees: the definition asks for it, and that way what is inside the root is 1 on average, (proof 4). That is why, with large n, the t looks like the normal.
Step 2: simplify
The inside the root go and you are left with (both are positive):
σ cancels. That is why the t is useful: it is computed without knowing σ.
In the picture, the two pieces: on top the normal, which needs σ; below the root of the chi-square over its degrees, which carries it too. When you divide, σ disappears and you are left with the statistic you compute from your data.
Dividing the chi-square by n instead of inside the root. Then σ does not cancel cleanly and an extra appears.
Result for the cheat sheet. ; t(k) symmetric, (k > 1), (k > 2).
Check it with R
With the six pings from the hook and with a simulation of afternoons of six pings:
six <- c(57.4, 52.9, 41.4, 37.3, 39.4, 47.8)
z_with_sigma <- sqrt(6) * (mean(six) - 40) / 6 # needs sigma = 6
t_with_s <- sqrt(6) * (mean(six) - 40) / sd(six) # does not need it
round(c(z = z_with_sigma, t = t_with_s), 3)
set.seed(2026)
tt <- replicate(10000, { x <- rnorm(6, 40, 6); sqrt(6) * (mean(x) - 40) / sd(x) })
round(c(q975 = unname(quantile(tt, 0.975)), t5 = qt(0.975, 5), normal = qnorm(0.975)), 2)
Output:
z t 2.463 1.844 q975 t5 normal 2.55 2.57 1.96
With σ = 6 known, the statistic of the six pings is 2.46; with S, 1.84 (in this sample S = 8.02 came out larger than σ). And the 97.5 % quantile of 10,000 statistics with S falls next to the one, 2.57, far from the normal’s 1.96.
Check you’ve got it: with the six pings from the hook, why does the statistic come out as 2.46 with σ and 1.84 with S, if the data are the same?
The numerator is the same: . The denominator changes: with σ and with S. Each one goes with its own distribution: 2.46 with the normal (1.96) and 1.84 with the t(5) (2.57).
Proof 8: the F for two variances, the reciprocal and the squared t
What we want to prove
For two independent SRSs from (size m) and (size n):
Why it matters. The F compares two variances: is the library wifi more irregular? Also, the inverse gives left-tail quantiles from tables that only have the right one, and links the two-sided t with the F.
Step 1: the two chi-squares
By proof 6, applied to each sample:
independent because each depends only on its own sample (rule 9).
Step 2: the ratio from the definition
If , they cancel and you are left with .
Step 3: the reciprocal
If , then : a ratio of two independent chi-squares with the roles swapped, so . Consequence for quantiles: , hence
The skipped step: if , then , because inverting positive numbers flips the inequality. So leaves to its left in an F(n, m): it is .
Step 4: the squared t
If , then . By proof 5, , and it is independent of Y (rule 9). It is a ratio of chi-squares with 1 and n degrees: .
In step 3, swapping the degrees of freedom without swapping the tail: . Taking the reciprocal flips the inequality: the left tail of one is the right tail of the other.
Result for the cheat sheet. ; ; ; ; .
Check it with R
round(c(qf(0.05, 14, 11), 1 / qf(0.95, 11, 14)), 4) # the reciprocal round(c(qt(0.975, 14)^2, qf(0.95, 1, 14)), 4) # t^2 is F(1, n): both tails of the t set.seed(2026) ff <- replicate(10000, var(rnorm(15, 40, 6)) / var(rnorm(12, 46, 6))) round(c(mean = mean(ff), mean_theoretical = 11 / 9, tail = mean(ff > qf(0.95, 14, 11))), 3)
Output:
[1] 0.3898 0.3898
[1] 4.6001 4.6001
mean mean_theoretical tail
1.221 1.222 0.053
The two numbers in each row agree. In the second, notice the t’s 0.975 against the F’s 0.95: is , which puts both tails of the t together. And the simulated ratio of variances has mean close to and exceeds the 95 % quantile 5 % of the time.
Check you’ve got it: if the tables only tell you that the 95 % quantile of an F(11, 14) is 2.57, what is the 5 % quantile of an F(14, 11)?
With step 3: , the 0.3898 in the R output. Careful: the degrees swap and the tail goes from 0.05 to 0.95.
Proof 9: the two-sample t and the paired t
What we want to prove
For two independent SRSs from and (the same σ, unknown), of sizes m and n:
And for paired data , with differences normal and independent between pairs: .
Why it matters. It compares two means without knowing σ: is the library wifi slower? And it brings everything together: the normal on top is proof 3; the chi-square at the bottom, proofs 5 and 6; and the ratio is built as in proof 7. If you understand this one, you have understood the topic.
Step 1: the normal in the numerator
By proof 3, . Standardising:
Step 2: the chi-square in the denominator
By proof 6, each sample gives a chi-square; they are independent, so by proof 5 they add up:
Z depends only on the means and Y only on the variances; by rules 9 and 10, they are independent.
What gets skipped: the degrees add up, (proof 5), and the last equality is the definition of . In step 3, since , its root is and σ goes.
Step 3: the ratio
Once again, σ cancels because it is the same in both samples. If they were different, they would not cancel and you would not get an exact t.
Step 4: paired data
If the two measurements are on the same unit (the same spot on campus in the morning and in the afternoon), X and Y are not independent and steps 1-3 do not apply. But the differences are an SRS from a normal , with . It is enough to apply proof 7 to them: , with the standard deviation of the differences.
Using the two-sample t with paired data. The formula gives a different number (usually a smaller t, because it does not use the fact that each pair shares a common part) and the degrees of freedom are instead of .
Result for the cheat sheet. Two samples with common σ: , . Paired: .
Check it with R
The course notes’ form, , must give the same number as step 3’s:
cs <- 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)
lib <- 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)
m <- length(cs); n <- length(lib)
sp <- sqrt(((m - 1) * var(cs) + (n - 1) * var(lib)) / (m + n - 2))
t_step3 <- (mean(cs) - mean(lib)) / (sp * sqrt(1 / m + 1 / n))
t_notes <- sqrt(m * n * (m + n - 2) / (m + n)) * (mean(cs) - mean(lib)) /
sqrt((m - 1) * var(cs) + (n - 1) * var(lib))
round(c(t_step3, t_notes), 4)
set.seed(2026)
tt <- replicate(10000, { a <- rnorm(15, 40, 6); b <- rnorm(12, 40, 6)
s <- sqrt((14 * var(a) + 11 * var(b)) / 25); (mean(a) - mean(b)) / (s * sqrt(1/15 + 1/12)) })
round(c(q975 = unname(quantile(tt, 0.975)), t25 = qt(0.975, 25)), 3)
Output:
[1] -2.1208 -2.1208 q975 t25 2.052 2.060
Both forms give −2.1208, the two-building t from the theory. And with two buildings with the same mean, the 97.5 % quantile of 10,000 statistics falls next to the one.
Check you’ve got it: with the 15 Computer Science pings (S = 6.19) and the 12 library ones (S = 7.25), what is the pooled standard deviation and why is it not the average of the two?
and , not : variances are averaged, not standard deviations, and each one is weighted by its degrees of freedom (14 versus 11).
Prove it yourself
Try each on paper before opening the solution.
- Exponentials and chi-square. If is an SRS from an , prove that .
- A ratio of exponentials. If X and Y are independent and , prove that .
- The variance of S². For an SRS from an , prove that .
Solution 1: exponentials and chi-square
The mgf of each is . By rule 5 with , that of is
which is the mgf of a . The are independent (rule 9), so by proof 5 their sum is a . This is the result that allows exact intervals for λ with qchisq in the confidence intervals topic.
Solution 2: a ratio of exponentials
By solution 1 with and n = 1, and , independent. Then
is a ratio of two independent chi-squares, each over its 2 degrees of freedom: . In R: mean(rexp(1e5) / rexp(1e5) <= 3) comes out close to pf(3, 2, 2) = 0.75.
Solution 3: the variance of S²
By proof 6, , and by proof 4, . Since , by the rule for the variance of :
With 15 Computer Science pings, : the standard deviation of is 13.61 ms², more than a third of σ² = 36. That is why the sample variance moves so much.
When to use each result
| If you are asked for… | Use | Watch out for… |
|---|---|---|
| Mean or variance of | Proof 1 | holds for any population; only the variance needs independence |
| That is unbiased | Proof 2 | the step |
| The distribution of a combination of normals | Proof 3 (mgf) | variances add with |
| That something is a chi-square | mgf (proofs 4 and 5) | write the mgf and read off the degrees |
| The distribution of | Proof 6 | n − 1 degrees, not n |
| A t | Build and check independence | that σ cancels |
| An F | Ratio of two chi-squares over their degrees | the order of the degrees |
| Comparing two means | Proof 9 | common σ; if paired, differences |
Common mistakes when proving
- Adding squares of deviations from as if they were independent standard normals. They are not: they add up to 0. With , degrees.
- Not justifying independence when building a t or an F. Write what each piece depends on (, , each sample) and cite the rule.
- Forgetting the from the chain rule when differentiating .
- Writing . With , : they add.
- Using the mgf-of-a-sum rule without independence. only if they are independent; in proof 6, the independence of Y and V comes from rule 10.
- Swapping the degrees of an F without flipping the tail (proof 8, step 3).
Try it in the R playground
Open the R playground on the site (or RStudio) and paste this script. It checks three results from this article by simulation:
set.seed(2026) # 1. E(S^2) = sigma^2 even if the population is not normal (exponential with mean 40) s2 <- replicate(20000, var(rexp(5, 1 / 40))) c(with_n1 = mean(s2), with_n = mean(s2 * 4 / 5), sigma2 = 1600) # 2. 2 * lambda * sum of exponentials is a chi^2(2n) (Prove it yourself, 1) lambda <- 1 / 40; n <- 6 u <- replicate(10000, 2 * lambda * sum(rexp(n, lambda))) hist(u, freq = FALSE, breaks = 40); curve(dchisq(x, 2 * n), add = TRUE, lwd = 2) # 3. Var(S^2) = 2 sigma^4 / (n - 1) with 15 pings (Prove it yourself, 3) v <- replicate(10000, var(rnorm(15, 40, 6))) c(simulated = var(v), theoretical = 2 * 36^2 / 14)
Things to look at:
- That with the mean of the variances comes out close to 1600 even though the population is exponential, and with n it falls short.
- That the histogram of
ufits the . - That the simulated variance of comes out close to 185.
- Replace
rnorm(15, 40, 6)withrexp(15, 1/40)in point 3: the formula stops holding, because proof 6 needs normality.
Summary
| Proof | Key idea | Result |
|---|---|---|
| 1. Sample mean | Linearity; independence for the variance | , |
| 2. unbiased | ||
| 3. Normals | Product of mgfs | |
| 4. Chi-square | It is a gamma(n/2, 1/2) | , mean n, variance 2n |
| 5. and sums | Gaussian integral; product of mgfs | , |
| 6. Sample variance | and solve for the mgf | |
| 7. One-sample t | Normal over root of chi-square; σ cancels | |
| 8. F | Ratio of chi-squares | ; ; |
| 9. Two samples | Normal of the difference and added chi-squares | ; paired, |
Three ideas to take away:
- Almost everything is proved with the mgf: write the sum’s as a product, simplify and recognise a known distribution’s.
- Every estimated parameter eats a degree of freedom. The decomposition shows it: the degree loses is the one keeps.
- The t and the F exist so that σ cancels. If σ does not disappear when you build the ratio, something is wrong (or the σs are not equal).
Now, on to the computer: the sampling distributions practice in R draws the three families and checks these results with thousands of ping samples. If a proof gets stuck, go back to the theory, where each result first appears with the campus wifi.
Next step: practiceSampling distributions — practice in R with the campus wifi, replicate, histograms, qchisq, qt and qf (and the curve that was off by one degree of freedom)Did this article help you? Here is how you can support SergioLearns →



