Confidence intervals — step-by-step proofs with the pivot method (and why the quantiles swap places)
In a class mock exam I was asked for the interval for the variance and I got a lower limit of 37.6 and an upper limit of 8.1. I handed it in like that, with both numbers correctly computed and in the wrong order. The lecturer wrote a single word next to it: “Empty?”. An interval whose left end is to the right of its right end contains nothing, not even the variance I had just estimated. The mistake was not in the arithmetic but in the last step: when I flipped the fraction I did not flip the quantiles. Since then I solve every interval as I do here, one inequality at a time.
In the confidence intervals theory we saw the formula for each interval and computed it with the Gáldar and Tazacorte bananas. Here is where each one comes from, step by step, with no jumps: the pivot, why it has the distribution it has and how to solve for the parameter. These are the derivations that come up in EC2, especially the exact exponential pivot. After each one, “Check it with R” tests it by simulation: if the formula is right, the interval must hit in 95 % of samples.
Table of Contents
Before you start: the rules we will use
Every proof cites these rules by number (“by rule 3”). The ones about distributions come from sampling distributions and from the random variable topics.
- Quantiles. , , (chi-squared) and (F) are the values that leave probability p to their left:
qnorm(p),qt(p, k),qchisq(p, k),qf(p, k1, k2). For the normal and the t, by symmetry, and . - The mean of a normal. If is an s.r.s. from , then .
- The variance of a normal. In the same sample, and it is independent of .
- The t. If and are independent, .
- The F and the sum of chi-squareds. If and are independent, and .
- Inequalities. Adding or subtracting the same thing to all three sides of changes nothing; multiplying by a positive number, neither; multiplying by a negative one reverses both inequalities. And if , taking reciprocals reverses them: .
- Gamma and rescaling. If are independent exponential(λ), . If Y has density and with , then . And is gamma.
- Asymptotic normality of the MLE. With large n, , and θ can be replaced by in the standard deviation.
Proof 1: the mean of a normal with known σ
What we want to prove
That, with an s.r.s. from and σ known, the interval for μ is
Where we are going and why it matters. It is the simplest interval and the mould for all the others: the eight proofs follow the same path. A pivot (a quantity with the sample and the parameter whose distribution we know completely), cut its tails to keep the central , and solve for the parameter. The pivot changes; the path does not.
What we start from
From rule 2: . And from the fact that standardising a normal gives an N(0, 1).
Step 1: the pivot
Standardising :
Z meets both conditions of a pivot: it depends on the sample (through ) and on μ, and the only unknown is μ (σ is known); its distribution, N(0, 1), does not depend on μ.
Step 2: cut off the tails
By rule 1, leaving in each tail:
Why in each tail: the normal is symmetric with its peak in the center, so the central range is the narrowest one that keeps inside. Any other split would also have confidence , but it would be longer.
Step 3: solve for μ, one operation at a time
Multiplying all three sides by (rule 6, nothing changes):
Subtracting from all three:
Multiplying by −1 (rule 6: both inequalities reverse, and the left-hand side moves to the right):
As every step is an equivalence, the event is the same and its probability is still . What is to the left of μ is L and to the right, U. ∎
Look at the drawing: the top box is a statement about Z, with μ fixed and moving; the bottom one, the same event written as a statement about where μ is relative to a moving range. Solving does not change the event, only how you read it.
Jumping from step 2 to the result by writing “ between and ” without multiplying by −1. Here it comes out right by luck (the interval is symmetric), but with the variance or the exponential that jump gives the interval backwards.
Result for the cheat sheet. μ, known σ: .
Check you’ve got it: with σ = 4 and 15 bunches, how long is the 95 % interval, and how many bunches would you need for it to be half as long?
It is twice the margin: . Doubling the bunches is not enough to halve it: n sits inside a square root, so you have to multiply it by 4. With 60, .
Check it with R
If the formula is right, with 10,000 samples of 15 bunches from , the 95 % interval should contain 38 in about 95 % of them:
set.seed(1)
mu <- 38; sigma <- 4; n <- 15; z <- qnorm(0.975)
hits <- replicate(10000, {
x <- rnorm(n, mu, sigma)
abs(mean(x) - mu) <= z * sigma / sqrt(n) # the same as L <= mu <= U
})
mean(hits)
Output:
[1] 0.9509
Just over 95 % of samples hit. Look at the condition inside: is exactly step 3 before solving.
Proof 2: the mean of a normal with unknown σ
What we want to prove
That, without knowing σ, the interval for μ is
Why it matters. You almost never know σ: from Gáldar you only have the 15 weights. This is the interval you will really use, the one t.test() gives. The idea: find another quantity that also contains σ so that, when you divide, it cancels.
What we start from
From rules 2, 3 and 4. The pivot of proof 1 no longer works: it contains σ, which is now unknown, so it would stop being a pivot.
Step 1: two independent pieces
By rule 2, . By rule 3, , and V is independent of , hence of Z.
Step 2: build the t
By rule 4 with :
What gets skipped here: V is independent of Z because Z only uses (μ, σ and n are fixed). And in the last equality the cancel, is left, and its square root is because both are positive.
Step 3: σ goes away
In the quotient, σ is in the denominator on top and in the one below, and it cancels:
Now T only depends on the sample (, S) and on μ, and its distribution depends neither on μ nor on σ: it is a pivot.
Step 4: solve
It is the same as proof 1, replacing σ with S and with (the t is also symmetric, rule 1): multiply by , subtract and multiply by −1. ∎
Giving the t n − 1 degrees of freedom “just because”. They come from the V of rule 3: the sum of squares around loses one degree of freedom because the add up to 0.
Result for the cheat sheet. μ, unknown σ: .
Check you’ve got it: with 15 bunches and unknown σ, which quantile do you use at 95 %, and how much longer is the interval than with z?
The one from the t with 14 degrees: qt(0.975, 14) = 2.14, against 1.96. With the same S, the interval is 2.14/1.96 = 1.09 times the z one: 9 % longer. That extra margin is what lifts the coverage from 93 % to 95 % in the simulation below.
Check it with R
With 15 bunches, we compare the t interval with the same one using z (that is, putting S where σ goes without changing the quantile):
set.seed(2)
mu <- 38; n <- 15
r <- replicate(10000, {
x <- rnorm(n, mu, 4); e <- sd(x) / sqrt(n)
c(t = abs(mean(x) - mu) <= qt(0.975, n - 1) * e,
z = abs(mean(x) - mu) <= qnorm(0.975) * e)
})
rowMeans(r)
Output:
t z 0.9494 0.9289
With the t it hits 95 %; with z, only about 93 %: the range is too short because it ignores that S varies too. The t corrects that.
Proof 3: the variance of a normal
What we want to prove
That the interval for is
with the quantiles of .
Why it matters. Two farms with the same mean weight can give very regular or very uneven bunches: the spread matters as much as the mean. And this is where solving goes wrong (as in my anecdote): the pivot is no longer symmetric and the parameter is in the denominator.
What we start from
From rule 3: . Q depends on the sample (through ) and on , and its distribution does not depend on : it is the pivot.
Step 1: cut off the tails
The chi-squared is not symmetric, so the two quantiles are different and both positive:
Why : leaves to its left and , to its right. With 14 degrees they are 5.63 and 26.12, at different distances from 14 (the mean of the ), because the right tail is longer.
Step 2: take reciprocals
All three sides are positive, so by rule 6, taking reciprocals reverses the inequalities:
Notice: , which was on the right, is now on the left.
Step 3: multiply
Multiplying by (rule 6, nothing changes):
∎ And as the square root is increasing, taking the root of all three sides gives the interval for σ.
In the drawing, the range of Q (top) goes from 5.63 to 26.12 with the 15 Gáldar bunches; when you move to , the 26.12 end lands on the small side (8.10) and 5.63 on the big one (37.60). A decreasing function swaps the ends.
My anecdote. If in step 2 you do not reverse the inequalities, the “interval” is (37.60, 8.10): empty. Always check that L < U.
Result for the cheat sheet. : , with from ; for σ, the root of the ends.
Check you’ve got it: with the 15 bunches from Gáldar, what is the 95 % interval for σ, not for σ²?
The one for is (8.10, 37.60). The square root is increasing, so it flips nothing: take the root of each end and leave each one where it is. You get (2.85, 6.13), which is not symmetric around s = 3.89.
Check it with R
set.seed(3)
n <- 15; sigma2 <- 16
q <- qchisq(c(0.975, 0.025), n - 1) # the big one first
hits <- replicate(10000, {
ci <- (n - 1) * var(rnorm(n, 38, 4)) / q
ci[1] <= sigma2 & sigma2 <= ci[2]
})
mean(hits)
galdar <- c(38.9, 36.7, 36.8, 28.8, 37.3, 38.6, 32.0, 34.0, 34.2, 36.0, 37.3, 36.4, 45.4, 39.6, 41.2)
round((15 - 1) * var(galdar) / q, 2)
Output:
[1] 0.9488 [1] 8.1 37.6
The interval hits in 95 % of samples, and with the Gáldar data it gives (8.10, 37.60), the one in the theory.
Proof 4: the difference of two normal means
What we want to prove
With from and from independent:
(a) with known, ;
(b) with unknown, , with .
Why it matters. It is the proof behind “do bunches from Gáldar and from Tazacorte weigh the same?”: if the interval for does not contain 0, there is a difference. The path is the usual one, with the difference of means playing the role of ; what is new is pooling the two in case (b).
What we start from
From rule 2 in each sample, and , independent; from the fact that the difference of independent normals is normal, with variance the sum of the variances; and from rules 3, 4 and 5.
Step 1: the difference of means
The variance is : subtracting does not subtract variances, because .
Step 2: case (a)
Standardising, , which is a pivot for . Solving as in proof 1 (with playing the role of ) gives interval (a). ∎
Step 3: case (b), the Z with a common σ
With , the denominator is :
Step 4: pool the two variances
By rule 3, and , independent (they come from independent samples). By rule 5:
The last equality is the definition of multiplied out: a mean of the two sample variances with weights and . And the degrees add up: 14 + 11 = 25.
And V is independent of Z, because the are independent of the means (rule 3).
Step 5: build the t
By rule 4 with :
σ cancels as in proof 2. Solving for gives interval (b). ∎
Subtracting the variances in step 1 (“the difference of means has variance “). With two similar variances it would come out almost 0 or negative. Variances of independent variables always add.
For the curious. If the variances are unequal and unknown, is not exactly a t; Welch approximated it with a t whose degrees of freedom depend on and . That is what t.test(x, y) does by default, and it is not proved in ME1.
Result for the cheat sheet. : known, ; equal, with .
Check you’ve got it: with 15 and 12 bunches, why does the t have 25 degrees and not 26?
Because each sample spends one degree estimating its own mean: 14 and 11, which rule 5 adds up. To get 26 you would have to use a single mean for both farms, which is exactly what you do not know is true.
Check it with R
We simulate step 4: if V is a with 15 and 12 bunches, its mean is 25 and its variance 50. And the pooled interval hits 95 %:
set.seed(4)
m <- 15; n <- 12; sigma <- 4
r <- replicate(10000, {
x <- rnorm(m, 38, sigma); y <- rnorm(n, 34, sigma)
sp2 <- ((m - 1) * var(x) + (n - 1) * var(y)) / (m + n - 2)
V <- (m + n - 2) * sp2 / sigma^2
e <- qt(0.975, m + n - 2) * sqrt(sp2) * sqrt(1 / m + 1 / n)
c(V = V, hits = abs((mean(x) - mean(y)) - 4) <= e)
})
round(c(mean_V = mean(r["V", ]), var_V = var(r["V", ]), coverage = mean(r["hits", ])), 3)
Output:
mean_V var_V coverage 24.979 50.376 0.949
The mean of V is around 25 and its variance 50, those of a , and the interval hits 95 %.
Proof 5: the ratio of variances
What we want to prove
That the interval for is
with the quantiles of .
Why it matters. Case (b) of proof 4 assumes equal variances, and this interval checks it: if it contains 1, there is no reason to doubt it. With Gáldar and Tazacorte, (0.19, 1.37) at 90 %, which contains 1.
What we start from
From rule 3 in each sample and from rule 5.
Step 1: the pivot
With and independent, by rule 5:
It depends on the samples and on the ratio (as , its reciprocal), and its distribution does not depend on it: it is a pivot.
Step 2: cut and solve
As with the variance, the F is not symmetric and only takes positive values: two different quantiles, in each tail, and with probability the pivot lies between them:
Dividing by :
Taking reciprocals (rule 6, it reverses):
∎ Once again the big quantile ends up in the lower limit.
The degrees of freedom the wrong way round. If the ratio is , the F is : the first degree, the numerator’s. var.test(x, y) does it in that order; var.test(y, x) gives the interval for the reciprocal ratio.
Result for the cheat sheet. : , with from .
Check you’ve got it: if you run var.test(tazacorte, galdar) at 90 %, what interval do you get and why?
(0.73, 5.14). The ratio is now the reciprocal, , with the F on degrees (11, 14). Since , the ends are the reciprocals of the previous ones, swapped: 1/1.3678 = 0.73 and 1/0.1947 = 5.14. Same conclusion: it contains 1.
Check it with R
galdar <- c(38.9, 36.7, 36.8, 28.8, 37.3, 38.6, 32.0, 34.0, 34.2, 36.0, 37.3, 36.4, 45.4, 39.6, 41.2) tazacorte <- c(32.6, 44.8, 30.8, 26.1, 28.9, 30.8, 39.9, 36.0, 34.7, 36.9, 29.7, 29.2) r <- var(galdar) / var(tazacorte) f <- qf(c(0.95, 0.05), 14, 11) # at 90 %: the big one first round(c(ratio = r, L = r / f[1], U = r / f[2]), 4) round(var.test(galdar, tazacorte, conf.level = 0.90)$conf.int, 4)
Output:
ratio L U 0.5332 0.1947 1.3678 [1] 0.1947 1.3678 attr(,"conf.level") [1] 0.9
By hand and with var.test, the same (0.1947, 1.3678).
Proof 6: the exact exponential pivot
This is the one that comes up in EC2 as a whole exercise: with little data, the asymptotic interval for λ is not reliable, and there is an exact pivot.
What we want to prove
With an s.r.s. from an exponential(λ) and :
(a) ;
(b) ;
(c) the exact interval for λ is , with the quantiles of ;
(d) the asymptotic interval is , with .
The path. The mgf says the sum is a gamma; a change of scale turns it into a chi-squared without λ, which is the pivot; and you solve. Part (d) goes separately.
What we start from
From rule 7 and from the moment generating function, which identifies a distribution.
Step 1: the distribution of T, with the mgf
The mgf of an exponential(λ) is for . As the are independent, the mgf of the sum is the product:
which is the mgf of a gamma. By uniqueness of the mgf, : (a).
Step 2: the density of U = 2λT
The density of T is , . U is a rescaling of T with , so by rule 7, with :
Piece by piece: the in front is the of rule 7, and every t is replaced by . Then cancels with the on top, and in the exponent .
Step 3: simplify
Gathering the powers of λ: . And the exponent becomes :
λ has disappeared. It is the density of a gamma, which by rule 7 is a (the degrees of freedom are twice the shape): (b).
Step 4: the exact interval
U depends on the sample (through T) and on λ, and its distribution does not depend on λ: it is a pivot. So
and dividing by (rule 6, nothing changes):
Nothing flips here: λ is in the numerator of the pivot. (c) ∎
Step 5: the asymptotic one
By rule 8: the information of one exponential observation is (computed in the properties of estimators), so . Replacing λ with in the standard deviation and standardising, , and solving as in proof 1 gives (d). ∎
The calculation that gets skipped: , because λ > 0.
In the drawing, the histogram of 10,000 values of simulated with 12 exponential waits matches the curve, and would with any λ: that is λ disappearing from the distribution.
Giving the χ² n degrees of freedom. It is : gamma is the with degrees. With n = 12, qchisq(…, 24), not qchisq(…, 12).
Result for the cheat sheet. Exponential(λ): , ; exact ; asymptotic .
Check you’ve got it: with 12 waiting times, which distribution do the quantiles of the exact 95 % interval come from, and what are they?
From the chi-squared with 2n = 24 degrees: is a gamma(12, 1/2), and the is the gamma(k/2, 1/2). They are 12.40 and 39.36 (the chi2_24 row below), and the interval is (12.40/(2T), 39.36/(2T)). Nothing flips: λ is on top in the pivot.
Check it with R
set.seed(6)
n <- 12; lambda <- 1 / 26
U <- replicate(10000, 2 * lambda * sum(rexp(n, lambda)))
round(rbind(simulated = quantile(U, c(0.025, 0.5, 0.975)),
chi2_24 = qchisq(c(0.025, 0.5, 0.975), 2 * n)), 2)
r <- replicate(10000, {
x <- rexp(n, lambda); l <- 1 / mean(x)
ex <- qchisq(c(0.025, 0.975), 2 * n) / (2 * sum(x))
as <- l + c(-1, 1) * qnorm(0.975) * l / sqrt(n)
c(exact_low = lambda < ex[1], exact_high = lambda > ex[2], # misses on each side
asym_low = lambda < as[1], asym_high = lambda > as[2])
})
round(rowMeans(r), 4)
Output:
2.5% 50% 97.5%
simulated 12.25 23.27 39.74
chi2_24 12.40 23.34 39.36
exact_low exact_high asym_low asym_high
0.0257 0.0235 0.0069 0.0368
The simulated quantiles of U match those of . The second part counts which side each interval misses on: exact_low is the proportion of samples in which λ falls below the range, and exact_high, above it. The exact one misses 2.6 % on one side and 2.4 % on the other, as it should (2.5 % + 2.5 %). The asymptotic one misses about as much in total (4.4 %), but almost always on the same side: 3.7 % of the time λ is above it and only 0.7 % below. That is because is not symmetric with 12 values (it has a long right tail), and the symmetric range does not capture that. With large n both sides even out; with little data, go for the exact one.
Proof 7: θ of a uniform(0, θ) with the maximum
What we want to prove
Lorries leave the farm on time, but reach the packing house with a delay that is uniform between 0 and θ minutes. With an s.r.s. from a uniform(0, θ), the MLE is the maximum, . We want to prove that is a pivot with on (0, 1), and that the shortest interval based on it is
Why it matters. There is no normal, t or chi-squared here: the pivot is built from the distribution of the maximum. And it shows that “equal tails” is a habit, not a rule: if the pivot’s density is not symmetric, there can be a shorter interval with the same confidence.
What we start from
From the distribution of the maximum (seen in the properties of estimators): for , because the maximum is small only if they all are.
Step 1: the pivot
For :
θ is gone: W has distribution (density ) with no parameters, and it depends on the sample and on θ. It is a pivot.
Step 2: any interval
If , solving for θ (taking reciprocals reverses, rule 6, then multiply by ):
Step 3: which one is shortest
The length is . To make it small, a has to be as big as possible and so does b. As W never exceeds 1, the biggest b is , and then gives . Substituting:
∎ The lower limit is the maximum itself, which makes perfect sense: θ cannot be smaller than the largest delay you have seen.
Why b = 1: a and b are tied by , so if b goes up, a goes up too. Raising b lengthens a little and raising a shortens, and the second wins: the length changes with b at rate , negative because a < b. That is why b is pushed to its ceiling, 1.
The drawing shows the density of W with n = 12, packed against 1. Two ways of leaving out 10 %: with equal tails (5 % on each side) or all on the left. The second cuts the area where the density is low, which is why it gives a shorter interval.
Using equal tails out of habit. It is valid (it has the required confidence), but it is not the shortest, and if the question asks for “the shortest interval”, it is the one with .
Result for the cheat sheet. Uniform(0, θ): has ; shortest interval .
Check you’ve got it: with the 12 lorries (maximum 22.9 minutes), what is the shortest 95 % interval?
, so minutes. Longer than the 90 % one, (22.9, 27.74): more confidence needs a wider range. The lower limit is still the maximum.
Check it with R
With the delays (in minutes) of 12 lorries and 90 % confidence:
delays <- c(5.2, 3.1, 7.3, 9.4, 21.2, 13.2, 13.0, 5.9, 8.2, 22.9, 10.4, 8.6)
n <- length(delays); mx <- max(delays); alpha <- 0.10
shortest <- c(mx, mx / alpha^(1 / n))
equal <- c(mx / (1 - alpha / 2)^(1 / n), mx / (alpha / 2)^(1 / n))
round(rbind(shortest = c(shortest, length = diff(shortest)), equal = c(equal, diff(equal))), 2)
set.seed(7)
mean(replicate(10000, { x <- runif(n, 0, 25); max(x) <= 25 & 25 <= max(x) / alpha^(1 / n) }))
Output:
length shortest 22.9 27.74 4.84 equal 23.0 29.39 6.40 [1] 0.8971
The shortest, (22.9, 27.74), is 4.84 minutes long; the equal-tails one, 6.40. And the shortest hits in 90 % of the simulated samples, as it should.
Proof 8: sample size
What we want to prove
(a) For the margin of error of the interval for the mean not to exceed δ, is enough.
(b) For a proportion, without knowing p, is enough.
Why it matters. The others go from the data to the interval; this one goes the other way: before collecting anything, how much data you need for the interval to be as narrow as you want. You solve the margin for n instead of μ.
What we start from
From the margin of each interval: for the mean and for the proportion (we write z for ).
Step 1: the mean
Everything is positive, so multiplying, dividing and squaring do not change the direction (rule 6):
(a) ∎ As n is a whole number, you take the first integer that satisfies it: you round up.
Step 2: the proportion, with p known
Same as step 1: .
Step 3: the worst case of p(1 − p)
Completing the square:
because a square is never negative. The maximum, 1/4, is reached at . So if , then also for any p. (b) ∎
In the drawing, the parabola peaks at 1/4 when . If the real proportion is far from 1/2 (like the 11.5 % of rejected bunches), the worst case asks for much more data than needed: 1068 against 435 for a 3-point error.
The two figures, with δ = 0.03: with no information, , rounded up to 1068; with , , rounded up to 435.
Rounding 61.46 to 61. With 61 bunches the margin is : the requirement is no longer met.
Result for the cheat sheet. Mean: (with a pilot S if σ is unknown). Proportion: or, with no information, . Always round up.
Check you’ve got it: with σ = 4 and 95 % confidence, how many bunches do you need for a margin of 0.5 instead of 1?
: 246 bunches, against 62. Halving the margin multiplies n by 4, because δ is squared.
Check it with R
z <- qnorm(0.975) round(c(n61 = z * 4 / sqrt(61), n62 = z * 4 / sqrt(62)), 4) # margin with 61 and with 62 p <- seq(0, 1, by = 0.1) round(p * (1 - p), 2)
Output:
n61 n62 1.0038 0.9957 [1] 0.00 0.09 0.16 0.21 0.24 0.25 0.24 0.21 0.16 0.09 0.00
With 61 bunches the margin is above 1 (1.0038); with 62 it is not (0.9957). And rises to 0.25 in the middle and falls symmetrically.
Prove it yourself
Three derivations in the style of EC2. Try them on paper before opening the solution.
- Let be an s.r.s. from with μ known. Prove that and derive the interval for .
See the solution to 1
Each , so its square is a , and the n of them are independent. By rule 5 (applied n − 1 times), . No degree of freedom is lost now because μ is not estimated.
Q is a pivot. With from , , and solving as in proof 3 (taking reciprocals flips it):
- With the pivot of proof 6, derive the exact interval for the exponential mean, , and compute it with the 40 lorries from the theory () at 95 %.
See the solution to 2
From , with all three sides positive, taking reciprocals (rule 6, it reverses):
With n = 40, the quantiles are from : qchisq(0.975, 80) = 106.63 and qchisq(0.025, 80) = 57.15. Then and the interval is (2115.8/106.63, 2115.8/57.15) = (19.84, 37.02) minutes, the one in the theory.
- Let be an s.r.s. from a Poisson(λ). Derive the asymptotic interval for λ.
See the solution to 3
The MLE is . From we get , so . By rule 8, , and replacing λ with in the standard deviation:
Solving as in proof 1: .
When to use each result
| If you are asked for… | Use | Watch out for… |
|---|---|---|
| an interval for μ of a normal | Z if σ is known, T with t(n − 1) if not | the 1 − α/2 quantile, not 1 − α |
| an interval for σ² or σ | taking reciprocals swaps the quantiles | |
| comparing two means | , variances that add | known, equal, unequal or paired? |
| comparing two variances | the F of | degrees in order: numerator first |
| an exact interval for λ of an exponential | 2n degrees, not n | |
| an interval for θ of a uniform(0, θ) | with | the shortest starts at the maximum |
| how much data is needed | solve for n from the margin | always round up |
Common mistakes when proving
- Solving without multiplying by −1. For the mean it works out by symmetry; for everything else, it does not.
- Not flipping when taking reciprocals (variance, ratio, uniform and the exponential mean). If L > U, a flip is missing.
- Keeping a pivot that still contains an unknown parameter. The Z with unknown σ is not a pivot; that is why you need the t.
- Forgetting independence when building the t or the F: rule 3 is what lets you divide Z by V.
- The χ² with n degrees for the exponential (it is 2n) or with n for the variance (it is n − 1, unless μ is known).
- Subtracting variances in a difference of means.
Try it in the R playground
Paste this script into the R playground. It checks the exact exponential pivot with another sample size and another rate:
set.seed(11)
n <- 5; lambda <- 0.2 # change n and lambda
U <- replicate(10000, 2 * lambda * sum(rexp(n, lambda)))
hist(U, breaks = 50, freq = FALSE, main = "2 lambda T", xlab = "u")
curve(dchisq(x, 2 * n), add = TRUE, lwd = 2, col = "red")
r <- replicate(10000, {
x <- rexp(n, lambda); l <- 1 / mean(x)
ex <- qchisq(c(0.025, 0.975), 2 * n) / (2 * sum(x))
as <- l + c(-1, 1) * qnorm(0.975) * l / sqrt(n)
c(exact_low = lambda < ex[1], exact_high = lambda > ex[2],
asym_low = lambda < as[1], asym_high = lambda > as[2])
})
round(rowMeans(r), 4)
What to look at:
- In Plots, the histogram of U and the red curve: they match for any
lambda. rowMeans(r): the exact one misses 2.5 % on each side; the asymptotic one, with n = 5, almost never below and 4 % above.- Raise n to 50: the two sides of the asymptotic one even out.
- Replace
2 * nwithninqchisq: the coverage of the exact one collapses (the degrees mistake).
Summary
| Interval | Pivot | Distribution |
|---|---|---|
| μ, known σ | N(0, 1) | |
| μ, unknown σ | t(n − 1) | |
| σ² | χ²(n − 1) | |
| μ₁ − μ₂, unknown common σ | t(m + n − 2) | |
| σ₁²/σ₂² | F(m − 1, n − 1) | |
| Exponential λ (exact) | χ²(2n) | |
| θ uniform(0, θ) | ||
| Sample size | margin ≤ δ | — |
Three ideas to take away:
- A pivot is half the proof. If you find a quantity with the parameter inside and a known distribution that does not depend on it, the interval comes out by solving.
- One inequality at a time. When you multiply by a negative or take reciprocals, everything flips: that is how the big quantile ends up in the lower limit of the variance.
- Check with a simulation. If your formula is right, it hits in 95 % of 10,000 samples; if not, the simulation tells you before the lecturer does.
Now it is time to practice it with data: in the confidence intervals practice you will simulate coverage, compare the two farms from start to finish and see when the interval for a proportion fails. And the confidence intervals exercises have derivations and calculations like those in EC2, with commented solutions.
Next step: practiceConfidence intervals in R — practice with simulated coverage, the two farms and when the asymptotic one failsDid this article help you? Here is how you can support SergioLearns →



