Skip to content

10-02: Exercises — One-Sample Z-Tests

Notes reference: 10-02: One-Sample Z-Tests


Q1: Right-tailed z-test for a mean

A training programme claims to raise mean output above 120 units. A sample of 50 trained workers averages 124.3 units. The process standard deviation is known to be σ = 14 units. Test at α = 0.05.

Solution

STEP 1  H₀: μ ≤ 120        H₁: μ > 120        RIGHT-tailed,  α = 0.05

STEP 2  σ known ✓   n = 50 ≥ 30 ✓   →  z-test

STEP 3  SE = 14/√50 = 14/7.0711 = 1.97990
        z  = (124.3 − 120)/1.97990 = 4.3/1.97990 = 2.17182

STEP 4  Critical value: z₀.₀₅ = 1.6449
        2.17182 > 1.6449                       →  REJECT H₀

        p-value = P(Z > 2.17182) = 0.014932
        0.0149 ≤ 0.05                          →  REJECT H₀

STEP 5  There is sufficient evidence at the 5% level to conclude that
        the training programme raises mean output above 120 units.

EFFECT SIZE   d = (124.3 − 120)/14 = 0.307   — small.
              The gain of 4.3 units is real but modest; whether it
              justifies the programme's cost is a business question.
=14/SQRT(50)                        ' 1.979899
=(124.3-120)/1.979899               ' 2.171825
=1-NORM.S.DIST(2.171825, TRUE)      ' 0.014932
=NORM.S.INV(0.95)                   ' 1.644854
se <- 14/sqrt(50); z <- (124.3 - 120)/se
c(se = se, z = z, p = pnorm(z, lower.tail = FALSE))

Q2: Left-tailed z-test

A supplier guarantees a mean tensile strength of at least 4,500 psi with σ = 220 psi. A sample of 30 specimens averages 4,412 psi. Test at α = 0.01.

Solution

STEP 1  H₀: μ ≥ 4500       H₁: μ < 4500       LEFT-tailed,  α = 0.01

STEP 2  σ known ✓   n = 30 ✓

STEP 3  SE = 220/√30 = 220/5.4772 = 40.1663
        z  = (4412 − 4500)/40.1663 = −88/40.1663 = −2.19086

STEP 4  Critical value: z₀.₀₁ = −2.3263
        −2.19086 is NOT beyond −2.3263          →  FAIL TO REJECT H₀

        p-value = P(Z < −2.19086) = 0.014235
        0.0142 > 0.01                           →  FAIL TO REJECT H₀

STEP 5  There is not sufficient evidence at the 1% level to conclude
        that the mean tensile strength falls below 4,500 psi.

NOTE  At α = 0.05 the same data WOULD reject (0.0142 ≤ 0.05).
      The conclusion depends on the significance level, which is exactly
      why α must be fixed BEFORE seeing the data. Reporting the p-value
      lets the reader apply their own threshold.
=(4412-4500)/(220/SQRT(30))         ' -2.190859
=NORM.S.DIST(-2.190859, TRUE)       ' 0.014235
=NORM.S.INV(0.01)                   ' -2.326348

Q3: Two-tailed z-test

A process should produce rods of mean length 15.00 cm with σ = 0.12 cm. A sample of 64 rods averages 15.037 cm. Test at α = 0.05 whether the process has drifted.

Solution

STEP 1  H₀: μ = 15.00      H₁: μ ≠ 15.00      TWO-tailed,  α = 0.05

STEP 3  SE = 0.12/√64 = 0.12/8 = 0.015
        z  = (15.037 − 15.000)/0.015 = 0.037/0.015 = 2.46667

STEP 4  Critical values: ±1.9600
        |2.46667| > 1.9600                      →  REJECT H₀

        p-value = 2 × P(Z > 2.46667) = 2(0.006817) = 0.013634
        0.0136 ≤ 0.05                           →  REJECT H₀

STEP 5  There is sufficient evidence at the 5% level that the process
        mean has drifted from 15.00 cm.

95% CI:  15.037 ± 1.96(0.015) = (15.0076, 15.0664)
         15.00 lies OUTSIDE — the same conclusion, plus the useful
         detail that the drift is between 0.008 and 0.066 cm.

Q4: z-test for a proportion

A manufacturer claims at most 3% of units are defective. An inspector finds 22 defectives in a random sample of 500. Test at α = 0.05.

Solution

STEP 1  H₀: p ≤ 0.03       H₁: p > 0.03       RIGHT-tailed,  α = 0.05

STEP 2  n p₀ = 500(0.03) = 15 ≥ 5     ✓
        n q₀ = 500(0.97) = 485 ≥ 5    ✓

STEP 3  p̂ = 22/500 = 0.044

        SE = √(p₀q₀/n) = √(0.03 × 0.97 / 500) = √0.0000582 = 0.0076289
                          ↑ uses p₀ = 0.03, NOT p̂

        z  = (0.044 − 0.030)/0.0076289 = 0.014/0.0076289 = 1.83513

STEP 4  Critical value: 1.6449
        1.83513 > 1.6449                        →  REJECT H₀

        p-value = P(Z > 1.83513) = 0.033235
        0.0332 ≤ 0.05                           →  REJECT H₀

STEP 5  There is sufficient evidence at the 5% level to conclude that
        the defect rate exceeds the claimed 3%.
=22/500                                     ' 0.044
=SQRT(0.03*0.97/500)                        ' 0.0076289
=(0.044-0.03)/0.0076289                     ' 1.835133
=1-NORM.S.DIST(1.835133, TRUE)              ' 0.033235
prop.test(22, 500, p = 0.03, alternative = "greater", correct = FALSE)
sqrt(prop.test(22, 500, p = 0.03, correct = FALSE)$statistic)   # |z| = 1.8351
binom.test(22, 500, p = 0.03, alternative = "greater")          # exact: p = 0.0421

Q5: The p₀ vs. trap

Redo Q4 using in the standard error instead of p₀. How much does the answer change, and which is correct?

Solution

WITH p̂ (WRONG for a hypothesis test):
    SE = √(0.044 × 0.956 / 500) = √0.00008413 = 0.0091721
    z  = 0.014 / 0.0091721 = 1.52637
    p  = P(Z > 1.52637) = 0.063458       →  FAIL TO REJECT at α = 0.05

WITH p₀ (CORRECT):
    z = 1.83513,  p = 0.033235           →  REJECT at α = 0.05

OPPOSITE CONCLUSIONS from the same data.

WHY p₀ IS RIGHT: the whole test is conducted ASSUMING H₀ is true. If
p = 0.03, then the standard error of p̂ IS √(0.03 × 0.97/n). Using p̂
estimates the SE under the alternative, which is not what the null
distribution requires.

WHEN p̂ IS RIGHT: in a CONFIDENCE INTERVAL (09-02), where there is no
hypothesized value to assume. That is the only place p̂ belongs in
the standard error.

Q6: Two-tailed proportion test

Historically 62% of customers renew. After a policy change, 340 of 600 customers renew. Has the renewal rate changed? Test at α = 0.05.

Solution

STEP 1  H₀: p = 0.62       H₁: p ≠ 0.62       TWO-tailed,  α = 0.05

STEP 2  n p₀ = 600(0.62) = 372 ≥ 5   ✓
        n q₀ = 600(0.38) = 228 ≥ 5   ✓

STEP 3  p̂ = 340/600 = 0.566667

        SE = √(0.62 × 0.38 / 600) = √(0.2356/600) = √0.00039267 = 0.0198159

        z  = (0.566667 − 0.62)/0.0198159 = −0.053333/0.0198159 = −2.69145

STEP 4  Critical values: ±1.9600
        |−2.69145| > 1.9600                     →  REJECT H₀

        p-value = 2 × P(Z < −2.69145) = 2(0.003558) = 0.007116
        0.0071 ≤ 0.05                           →  REJECT H₀

STEP 5  There is sufficient evidence at the 5% level that the renewal
        rate has CHANGED — and the direction is DOWN, from 62% to 56.7%.

95% CI for p (uses p̂, not p₀):
        SE_CI = √(0.566667 × 0.433333/600) = 0.0202301
        0.566667 ± 1.96(0.0202301) = (0.5270, 0.6063)
        0.62 lies outside — the same conclusion.

Q7: Difference of two proportions

Two landing pages are tested: page A converts 168 of 1,200 visitors; page B converts 210 of 1,300. Is there a difference? Test at α = 0.05.

Solution

STEP 1  H₀: p₁ = p₂        H₁: p₁ ≠ p₂        TWO-tailed,  α = 0.05

STEP 2  p̂₁ = 168/1200 = 0.140      p̂₂ = 210/1300 = 0.161538
        All counts well above 5    ✓

STEP 3  POOLED proportion (H₀ says the two rates are equal):

        p̄ = (168 + 210)/(1200 + 1300) = 378/2500 = 0.1512
        q̄ = 0.8488

        SE = √( p̄ q̄ (1/n₁ + 1/n₂) )
           = √( 0.1512 × 0.8488 × (1/1200 + 1/1300) )
           = √( 0.128339 × 0.00160256 )
           = √0.000205671
           = 0.0143412

        z  = (0.140 − 0.161538)/0.0143412 = −0.021538/0.0143412 = −1.50186

STEP 4  |−1.50186| < 1.9600                    →  FAIL TO REJECT H₀
        p-value = 2 × P(Z < −1.50186) = 2(0.066562) = 0.133124
        0.1331 > 0.05                          →  FAIL TO REJECT H₀

STEP 5  There is not sufficient evidence at the 5% level of a difference
        in conversion rate between the two pages.

95% CI for p₁ − p₂ (UNpooled SE, because there is no null to assume):
        SE = √(0.140×0.860/1200 + 0.161538×0.838462/1300) = 0.0143011
        (−0.02154) ± 1.96(0.0143011) = (−0.0496, 0.0067)
        The interval CONTAINS 0 — consistent with the test.

BUSINESS READING: page B looks 2.2 points better, but the data cannot
rule out that it is 0.7 points WORSE. Run the test longer before switching.
=(168+210)/(1200+1300)                                       ' pooled p̄ 0.1512
=SQRT(0.1512*0.8488*(1/1200+1/1300))                         ' 0.0143412
=(168/1200-210/1300)/0.0143412                               ' -1.501861
=2*NORM.S.DIST(-ABS(-1.501861), TRUE)                        ' 0.133124
prop.test(c(168, 210), c(1200, 1300), correct = FALSE)
# X-squared = 2.2556, df = 1, p-value = 0.1331
sqrt(2.2556)     # = |z| = 1.5019
from statsmodels.stats.proportion import proportions_ztest
proportions_ztest(np.array([168, 210]), np.array([1200, 1300]))
# (-1.50186, 0.13312)

Q8: One tail or two — and why it matters

A researcher gets z = 1.78 on a mean test. Compute the p-value for a right-tailed test and for a two-tailed test. Decide at α = 0.05 in each case. What does this reveal about choosing the tail after seeing the data?

Solution

RIGHT-TAILED:  p = P(Z > 1.78) = 0.037538        ≤ 0.05  →  REJECT
TWO-TAILED:    p = 2 × 0.037538 = 0.075076       > 0.05  →  FAIL TO REJECT

Same data. Opposite conclusions.

WHY THIS IS DANGEROUS
    A researcher who runs a two-tailed test, sees p = 0.075, and then
    "remembers" they expected a positive effect — switching to a one-tailed
    test to reach p = 0.038 — has doubled their real Type I error rate
    from 5% to 10%. This is p-hacking, and it is a leading cause of
    irreproducible results.

THE RULE
    Choose the tail BEFORE collecting data, and justify it from theory
    or prior work. A one-tailed test says "a difference in the other
    direction would be treated exactly like no difference at all" —
    which is rarely true in practice.

    When in doubt, use TWO tails. It is the conservative, defensible
    default, and it is what almost all software reports by default.

⬅️ Previous: 10-01: Exercises — Hypothesis Testing Fundamentals ➡️ Next: 11-01: Exercises — One-Sample t-Test