11-01: Exercises — One-Sample t-Test¶
Notes reference: 11-01: One-Sample t-Test
Q1: Critical t values¶
Find the critical value(s) for each.
| Test | α |
n |
Critical t |
|---|---|---|---|
| Two-tailed | 0.05 | 20 | ? |
| Right-tailed | 0.05 | 20 | ? |
| Left-tailed | 0.01 | 12 | ? |
| Two-tailed | 0.01 | 31 | ? |
| Two-tailed | 0.10 | 8 | ? |
Solution
| Test | α |
df = n−1 |
Critical t |
|---|---|---|---|
| Two-tailed | 0.05 | 19 | ±2.0930 |
| Right-tailed | 0.05 | 19 | +1.7291 |
| Left-tailed | 0.01 | 11 | −2.7181 |
| Two-tailed | 0.01 | 30 | ±2.7500 |
| Two-tailed | 0.10 | 7 | ±1.8946 |
=T.INV.2T(0.05, 19) ' 2.09302 two-tailed
=T.INV(0.95, 19) ' 1.72913 right-tailed
=T.INV(0.01, 11) ' -2.71808 left-tailed
=T.INV.2T(0.01, 30) ' 2.75000
=T.INV.2T(0.10, 7) ' 1.89458
T.INVtakes a left-tail probability;T.INV.2Ttakes the total two-tailed area.T.INV(0.975, 19)andT.INV.2T(0.05, 19)both give 2.093.
Q2: Two-tailed t-test from summary statistics¶
A cereal box should contain 500 g. A sample of 25 boxes gives x̄ = 495.8 g with s = 9.4 g. Test at α = 0.05.
Solution
STEP 1 H₀: μ = 500 H₁: μ ≠ 500 TWO-tailed, α = 0.05
STEP 2 σ unknown (s computed from the data) → t-test
n = 25, assume fill weights are approximately normal
df = 24
STEP 3 SE = 9.4/√25 = 9.4/5 = 1.88
t = (495.8 − 500)/1.88 = −4.2/1.88 = −2.23404
STEP 4 Critical values: ±t(0.025, 24) = ±2.06390
|−2.23404| > 2.06390 → REJECT H₀
p-value = 2 × P(T₂₄ < −2.23404) = 2(0.017562) = 0.035124
0.0351 ≤ 0.05 → REJECT H₀
STEP 5 There is sufficient evidence at the 5% level to conclude that the
mean fill weight differs from 500 g. The boxes are UNDERFILLED
by about 4.2 g on average.
REPORT: t(24) = −2.23, p = .035, d = −0.45, 95% CI [491.92, 499.68]
CI: 495.8 ± 2.06390(1.88) = 495.8 ± 3.880 = (491.92, 499.68)
500 lies OUTSIDE — the same conclusion.
d : (495.8 − 500)/9.4 = −0.447 (small-to-medium)
=9.4/SQRT(25) ' 1.88
=(495.8-500)/1.88 ' -2.234043
=T.INV.2T(0.05, 24) ' 2.063899
=T.DIST.2T(ABS(-2.234043), 24) ' 0.035124
=495.8-T.INV.2T(0.05,24)*1.88 ' 491.920
=495.8+T.INV.2T(0.05,24)*1.88 ' 499.680
xbar <- 495.8; s <- 9.4; n <- 25
se <- s/sqrt(n); t <- (xbar - 500)/se
c(se = se, t = t, p = 2*pt(-abs(t), n-1),
lo = xbar - qt(0.975, n-1)*se, hi = xbar + qt(0.975, n-1)*se)
Q3: One-tailed t-test from raw data¶
A supplier claims mean delivery time is at most 3 days. A customer records 12 deliveries:
Test at α = 0.05 whether deliveries take longer than claimed.
Solution
STEP 1 H₀: μ ≤ 3 H₁: μ > 3 RIGHT-tailed, α = 0.05
STEP 2 n = 12, σ unknown → t-test, df = 11
Check a boxplot first: no outliers, roughly symmetric ✓
STEP 3 Σx = 43.7 x̄ = 43.7/12 = 3.64167
Σ(x − x̄)² = 3.24917 → s² = 3.24917/11 = 0.29538, s = 0.54349
SE = 0.54349/√12 = 0.54349/3.46410 = 0.15689
t = (3.64167 − 3)/0.15689 = 0.64167/0.15689 = 4.09000
STEP 4 Critical value: t(0.05, 11) = 1.79588
4.09000 > 1.79588 → REJECT H₀
p-value = P(T₁₁ > 4.09000) = 0.000895
0.00090 ≤ 0.05 → REJECT H₀
STEP 5 There is very strong evidence at the 5% level that mean delivery
time exceeds the claimed 3 days — by about 0.64 days on average.
EFFECT SIZE d = 0.64167/0.54349 = 1.181 — very large.
=AVERAGE(A2:A13) ' 3.641667
=STDEV.S(A2:A13) ' 0.543488
=(AVERAGE(A2:A13)-3)/(STDEV.S(A2:A13)/SQRT(12)) ' 4.090003
=T.DIST.RT(4.090003, 11) ' 0.000895
=T.INV(0.95, 11) ' 1.795885
x <- c(3.2,4.1,2.8,3.9,4.5,3.1,3.7,4.2,2.9,3.8,4.0,3.5)
t.test(x, mu = 3, alternative = "greater")
# t = 4.09, df = 11, p-value = 0.0008953
# 95 percent confidence interval: 3.3599 Inf
# mean of x: 3.641667
boxplot(x, horizontal = TRUE) # assumption check FIRST
shapiro.test(x)
x = np.array([3.2,4.1,2.8,3.9,4.5,3.1,3.7,4.2,2.9,3.8,4.0,3.5])
stats.ttest_1samp(x, 3, alternative="greater")
Q4: t or z?¶
Decide which test applies and give the critical value at α = 0.05, two-tailed.
n = 45,σ = 6.2knownn = 45,s = 6.2computedn = 9,s = 2.1, population known to be normaln = 9,s = 2.1, population strongly skewedn = 250,s = 30
Solution
1. Z-TEST, critical ±1.9600
2. t-TEST, df = 44, critical ±2.0154
3. t-TEST, df = 8, critical ±2.3060
4. NEITHER is safe. n = 9 from a strongly skewed population fails both
the normality assumption and the CLT.
→ transform (log), use the Wilcoxon signed-rank test, or bootstrap.
5. t-TEST, df = 249, critical ±1.9695 ≈ z
NOTE ON ROW 5: at df = 249 the t and z critical values agree to two
decimals. Large-sample t and z tests give practically identical answers —
which is why "use t whenever you estimated σ" costs you nothing.
Q5: Interpret a software output¶
One Sample t-test
data: scores
t = -1.6248, df = 29, p-value = 0.115
alternative hypothesis: true mean is not equal to 75
95 percent confidence interval:
70.7836 75.4831
sample estimates:
mean of x
73.13333
- What were the hypotheses?
- What is
n? - Decide at
α = 0.05. - Is the conclusion consistent with the CI?
- Estimate
s.
Solution
1. H₀: μ = 75 H₁: μ ≠ 75 (two-tailed, from "not equal to 75")
2. df = n − 1 = 29 → n = 30
3. p = 0.115 > 0.05 → FAIL TO REJECT H₀.
There is not sufficient evidence that the mean differs from 75.
4. YES. The 95% CI (70.78, 75.48) CONTAINS 75, which is exactly the
condition for failing to reject at α = 0.05.
5. Work backwards from the CI half-width:
E = (75.4831 − 70.7836)/2 = 2.34975
t(0.025, 29) = 2.04523
SE = E / t = 2.34975/2.04523 = 1.14889
s = SE × √n = 1.14889 × √30 = 1.14889 × 5.47723 = 6.2926
Cross-check with the printed t:
t = (73.13333 − 75)/1.14889 = −1.6248 ✓ matches exactly.
Q6: Assumption checks¶
Before running a one-sample t-test on 22 observations, what do you check and how?
Solution
1. INDEPENDENCE — from the DESIGN, not the data. Was it a random sample?
Are the observations from distinct units? No software test for this.
2. NORMALITY of the population (matters at n = 22).
Boxplot → symmetric? outliers?
Q-Q plot → do the points hug the line? ← the most informative check
Shapiro-Wilk → H₀: normal. A large p is reassuring.
3. OUTLIERS — the t-test is robust to mild non-normality but NOT to
outliers, because a single extreme value moves both x̄ and s.
x <- rnorm(22, 100, 15)
par(mfrow = c(1, 3))
hist(x, breaks = 8, col = "#8A5FBF", border = "white", main = "Histogram")
boxplot(x, col = "#0FA3A3", main = "Boxplot")
qqnorm(x, pch = 19); qqline(x, col = "#0FA3A3", lwd = 2)
par(mfrow = c(1, 1))
shapiro.test(x)
boxplot.stats(x)$out # any flagged outliers?
fig, axes = plt.subplots(1, 3, figsize=(12, 3))
axes[0].hist(x, bins=8, color="#8A5FBF", edgecolor="white")
axes[1].boxplot(x)
stats.probplot(x, dist="norm", plot=axes[2])
stats.shapiro(x)
=SKEW(A2:A23) ' near 0 if symmetric
=KURT(A2:A23) ' near 0 if normal (Excel reports EXCESS kurtosis)
' Q-Q plot: sort into column B, then C2: =NORM.S.INV((ROW()-1.5)/22)
' scatter B against C — a straight line means normal
Q7: When the assumptions fail¶
You have 14 observations with one clear outlier and obvious right skew. Give three defensible options.
Solution
OPTION 1 — INVESTIGATE THE OUTLIER
Data-entry error, wrong units, or a different population? If it is a
documented error, fix or remove it and say so. If it is genuine, keep it.
OPTION 2 — TRANSFORM
Right-skewed positive data often becomes symmetric under a log
transform. Run the t-test on log(x) — but note that you are then
testing the GEOMETRIC mean, and the CI back-transforms to a ratio,
not a difference.
t.test(log(x), mu = log(mu0))
OPTION 3 — NONPARAMETRIC TEST
The Wilcoxon signed-rank test tests the MEDIAN and needs only
symmetry of the differences, not normality.
wilcox.test(x, mu = mu0)
stats.wilcoxon(x - mu0)
OPTION 4 — BOOTSTRAP
Resample with replacement and build a percentile CI. Assumes nothing
about the distribution's shape.
boot_means <- replicate(10000, mean(sample(x, replace = TRUE)))
quantile(boot_means, c(0.025, 0.975))
WHAT NOT TO DO
Do not silently delete the outlier because the p-value improves.
Do not run the t-test and omit the diagnostics from the write-up.
Report the sensitivity: "with and without the outlier, the conclusion
is / is not the same."
Q8: Report it properly¶
Given x̄ = 68.4, s = 11.2, n = 36, μ₀ = 65, two-tailed, α = 0.05, produce a complete write-up.
Solution
COMPUTATION
df = 35
SE = 11.2/√36 = 11.2/6 = 1.86667
t = (68.4 − 65)/1.86667 = 3.4/1.86667 = 1.82143
critical t(0.025, 35) = 2.03011
p = 2 × P(T₃₅ > 1.82143) = 2(0.038538) = 0.077076
d = (68.4 − 65)/11.2 = 0.3036
95% CI = 68.4 ± 2.03011(1.86667) = 68.4 ± 3.789 = (64.61, 72.19)
DECISION
|1.82143| < 2.03011 and p = 0.077 > 0.05 → FAIL TO REJECT H₀
WRITE-UP
"A one-sample t-test found no significant difference between the
sample mean (M = 68.4, SD = 11.2, n = 36) and the reference value
of 65, t(35) = 1.82, p = .077, d = 0.30, 95% CI [64.61, 72.19].
The confidence interval includes 65, so a mean of 65 remains
plausible. However, the interval also extends to 72.2, so a
practically meaningful increase has NOT been ruled out — the study
is simply not precise enough to distinguish the two. A larger
sample would be needed to resolve the question."
WHY THAT LAST PARAGRAPH MATTERS
"p > 0.05" is NOT evidence that μ = 65. Failing to reject is not
accepting. The confidence interval is what tells the reader how much
uncertainty remains — which is why it belongs in every report.
⬅️ Previous: 10-02: Exercises — One-Sample Z-Tests ➡️ Next: 11-02: Exercises — Two-Sample t-Test