Skip to content

09-01: Exercises — Confidence Interval for a Mean

Notes reference: 09-01: Confidence Interval for a Mean


Q1: z-interval (σ known)

A sample of n = 64 light bulbs has x̄ = 1,190 hours. The manufacturing process is known to have σ = 120 hours.

Build 90%, 95%, and 99% confidence intervals for μ.

Solution

SE = σ/√n = 120/√64 = 120/8 = 15.0

90%:  z = 1.6449   E = 24.67   →  1190 ± 24.67  =  (1165.3, 1214.7)
95%:  z = 1.9600   E = 29.40   →  1190 ± 29.40  =  (1160.6, 1219.4)
99%:  z = 2.5758   E = 38.64   →  1190 ± 38.64  =  (1151.4, 1228.6)
Higher confidence  →  WIDER interval.
    90% width = 49.3 hours
    95% width = 58.8 hours
    99% width = 77.3 hours

You cannot buy confidence without paying in precision.
=CONFIDENCE.NORM(0.10, 120, 64)     ' 24.673
=CONFIDENCE.NORM(0.05, 120, 64)     ' 29.400
=CONFIDENCE.NORM(0.01, 120, 64)     ' 38.637
z <- qnorm(c(0.95, 0.975, 0.995))
1190 + outer(z * 120/8, c(-1, 1))

Q2: t-interval (σ unknown)

A sample of 18 households has a mean monthly electricity bill of $142.60 with s = $28.40.

Build a 95% confidence interval.

Solution

n = 18,  df = 17,  t(0.025, 17) = 2.1098

SE = 28.40/√18 = 28.40/4.2426 = 6.6940

E  = 2.1098 × 6.6940 = 14.123

CI = 142.60 ± 14.12  =  ($128.48, $156.72)
INTERPRETATION
"We are 95% confident that the mean monthly electricity bill for all
households in this population is between $128.48 and $156.72."

The z-interval would have used 1.96 instead of 2.1098, giving ±13.12 —
about a dollar narrower, and WRONG, because σ was estimated from the data.
=CONFIDENCE.T(0.05, 28.40, 18)     ' 14.123
=142.60-14.123                     ' 128.477
=142.60+14.123                     ' 156.723
=T.INV.2T(0.05, 17)                ' 2.10982
xbar <- 142.60; s <- 28.40; n <- 18
tc <- qt(0.975, n - 1)
xbar + c(-1, 1) * tc * s/sqrt(n)      # 128.477 156.723
xbar, s, n = 142.60, 28.40, 18
tc = stats.t.ppf(0.975, n - 1)
xbar - tc*s/np.sqrt(n), xbar + tc*s/np.sqrt(n)

Q3: z or t?

For each, choose the correct interval and give the critical value.

Situation z or t? Critical value (95%)
n = 40, σ = 8 known ? ?
n = 40, s = 8 computed ? ?
n = 12, s = 3.2, population normal ? ?
n = 12, s = 3.2, population strongly skewed ? ?
n = 500, s = 22 ? ?

Solution

Situation z or t? Critical value (95%)
n = 40, σ known z 1.960
n = 40, s computed t, df = 39 2.023
n = 12, s, normal population t, df = 11 2.201
n = 12, s, strongly skewed Neither is safe
n = 500, s t, df = 499 1.965 ≈ z
Row 4: with n = 12 from a strongly skewed population, neither the CLT nor
the normality assumption holds. Options: transform the data (log),
use a nonparametric method (sign test, Wilcoxon), or bootstrap the CI.

Row 5: at df = 499 the t critical value (1.9647) is essentially z (1.9600).
This is why large-sample z and t intervals agree to three decimals.

Q4: Interpret correctly

A 95% CI for the mean commute time is (24.1, 31.7) minutes. Mark each statement true or false.

  1. 95% of commutes are between 24.1 and 31.7 minutes.
  2. There is a 95% probability that μ lies in (24.1, 31.7).
  3. If we repeated this study many times, about 95% of the intervals produced would contain μ.
  4. We are 95% confident the true mean commute time is between 24.1 and 31.7 minutes.
  5. The sample mean is 27.9 minutes.
  6. A hypothesis test of H₀: μ = 30 would not be rejected at α = 0.05.

Solution

1. FALSE — that describes individual commutes, not the mean. A PREDICTION
           interval for one commute would be much wider.

2. FALSE — μ is a fixed constant. It either is or is not in this interval.
           The 95% describes the long-run behaviour of the PROCEDURE.

3. TRUE  — this is the correct frequentist definition.

4. TRUE  — the standard, accepted shorthand for #3.

5. TRUE  — the interval is symmetric about x̄, so
           x̄ = (24.1 + 31.7)/2 = 27.9  ✓

6. TRUE  — 30 lies INSIDE the interval, so H₀: μ = 30 is not rejected
           at α = 0.05. (H₀: μ = 22 WOULD be rejected — 22 is outside.)

Q5: Sample size for a mean

A researcher wants to estimate mean household income with a margin of error of $500 at 95% confidence. A pilot study gives s ≈ $6,200.

  1. Required n
  2. Required n for E = $250
  3. Required n for E = $500 at 99% confidence

Solution

        ( z σ )²
n  =   ( ───── )       ALWAYS round UP
        (  E  )

1.  n = (1.96 × 6200 / 500)²  = (24.304)²  = 590.68  →  n = 591

2.  n = (1.96 × 6200 / 250)²  = (48.608)²  = 2362.7  →  n = 2363
    Halving E QUADRUPLES the sample (591 → 2363).

3.  n = (2.5758 × 6200 / 500)² = (31.940)² = 1020.2  →  n = 1021
    Going from 95% to 99% confidence at the same precision nearly
    DOUBLES the sample.
=ROUNDUP((NORM.S.INV(0.975)*6200/500)^2, 0)     ' 591
=ROUNDUP((NORM.S.INV(0.975)*6200/250)^2, 0)     ' 2363
=ROUNDUP((NORM.S.INV(0.995)*6200/500)^2, 0)     ' 1021
n_for_mean <- function(sigma, E, conf = 0.95)
  ceiling((qnorm(1 - (1-conf)/2) * sigma / E)^2)
n_for_mean(6200, 500); n_for_mean(6200, 250); n_for_mean(6200, 500, 0.99)

Q6: From raw data

Fifteen service calls (minutes):

22  31  28  19  35  27  24  33  29  21  30  26  32  25  29

Build a 95% CI for the mean.

Solution

n = 15,  Σx = 411,  x̄ = 27.4
Σ(x − x̄)² = 295.6   →   s² = 295.6/14 = 21.114,   s = 4.5951

SE = 4.5951/√15 = 4.5951/3.8730 = 1.18645

df = 14,  t(0.025, 14) = 2.14479

E  = 2.14479 × 1.18645 = 2.5447

CI = 27.4 ± 2.54  =  (24.86, 29.94) minutes
=AVERAGE(A2:A16)                                          ' 27.4
=STDEV.S(A2:A16)                                          ' 4.5951
=CONFIDENCE.T(0.05, STDEV.S(A2:A16), COUNT(A2:A16))       ' 2.5447
' Or: Data ▸ Data Analysis ▸ Descriptive Statistics
'     tick "Confidence Level for Mean: 95%"  →  reports E directly
x <- c(22,31,28,19,35,27,24,33,29,21,30,26,32,25,29)
t.test(x)
#  mean of x: 27.4
#  95 percent confidence interval: 24.8553 29.9447
t.test(x, conf.level = 0.99)$conf.int
x = np.array([22,31,28,19,35,27,24,33,29,21,30,26,32,25,29])
stats.t.interval(0.95, len(x)-1, x.mean(), stats.sem(x))

Q7: What makes it narrower?

Starting from a 95% CI of (24.86, 29.94) based on n = 15, state the effect of each change.

  1. Raise confidence to 99%
  2. Increase n to 60 (same , same s)
  3. The data turns out to be more variable (s doubles)
  4. Drop confidence to 90%

Solution

Current: E = 2.545, width = 5.09

1.  99% confidence:  t(0.005, 14) = 2.9768
    E = 2.9768 × 1.18645 = 3.532   →  width 7.06     WIDER

2.  n = 60:  SE = 4.5951/√60 = 0.59323,  t(0.025, 59) = 2.0010
    E = 2.0010 × 0.59323 = 1.187    →  width 2.37    NARROWER
    Roughly halved — because n quadrupled.

3.  s = 9.1902:  SE = 2.3729,  t unchanged at 2.14479
    E = 5.089                       →  width 10.18   WIDER
    Doubling s doubles the width.

4.  90% confidence:  t(0.05, 14) = 1.7613
    E = 1.7613 × 1.18645 = 2.090    →  width 4.18    NARROWER

SUMMARY
    ↑ confidence  →  wider
    ↑ n           →  narrower (by √n)
    ↑ s           →  wider (proportionally)

Q8: Confidence interval for a variance

Using the Q6 data (n = 15, s = 4.5951), build a 95% CI for σ² and for σ.

Solution

df = 14,  α = 0.05

χ²(0.025, 14) = 26.119        (right-tail area 0.025)
χ²(0.975, 14) =  5.629        (right-tail area 0.975)

         (n−1)s²                 14 × 21.114        295.6
Lower  = ─────────────────  =  ──────────────  =  ─────────  =  11.318
          χ²(α/2)                  26.119           26.119

         (n−1)s²                    295.6
Upper  = ─────────────────  =  ─────────────  =  52.514
          χ²(1−α/2)                 5.629

95% CI for σ²:  (11.32, 52.51)
95% CI for σ :  (√11.32, √52.51)  =  (3.36, 7.25) minutes
NOTICE how ASYMMETRIC this is about s² = 21.11 —
   21.11 − 11.32 =  9.79 below
   52.51 − 21.11 = 31.40 above
The chi-square distribution is right-skewed, so the interval is too.

WARNING: this procedure requires the population to be NORMAL and is
NOT robust to that assumption, unlike the t-interval for the mean.
=(15-1)*STDEV.S(A2:A16)^2/CHISQ.INV.RT(0.025, 14)     ' 11.318
=(15-1)*STDEV.S(A2:A16)^2/CHISQ.INV.RT(0.975, 14)     ' 52.514
=SQRT(D1) & " to " & SQRT(D2)                          ' 3.364 to 7.247
n <- 15; s2 <- var(x)
c(lower = (n-1)*s2/qchisq(0.975, n-1),
  upper = (n-1)*s2/qchisq(0.025, n-1))
sqrt(c((n-1)*s2/qchisq(0.975, n-1), (n-1)*s2/qchisq(0.025, n-1)))

⬅️ Previous: 08-02: Exercises — Sampling Distributions and the Central Limit Theorem ➡️ Next: 09-02: Exercises — Confidence Interval for a Proportion