Statistics — Inferential Methods

Hypothesis Testing
Making Decisions from Sample Data

Collect a sample, form a claim, and decide whether the data supports it or forces you to revise it. Hypothesis testing is the formal language of scientific inference — p-values, test statistics, critical regions, and the ever-present risk of being wrong.

5Core Steps
10Worked Examples
2Error Types
10Quiz Questions
Share this page

§ 01What Is a Hypothesis Test?

A hypothesis test is a formal procedure for using sample data to decide between two competing claims about a population parameter. One claim is assumed true until evidence forces us to reconsider it; the other is what we suspect or wish to detect.

Suppose a factory claims its machines fill bags to a mean weight of 500 g. You weigh a random sample of 40 bags and find a sample mean of 496 g. Is this discrepancy just random variation, or is there real evidence that the machine is under-filling? Hypothesis testing gives you a principled, quantitative answer.

The key insight is that we never prove anything with a sample — we only assess the strength of the evidence against an assumed baseline. This asymmetry shapes every part of the procedure.

The Five-Step Framework
1. State H0 and H1
2. Choose significance level α
3. Compute the test statistic
4. Find the p-value (or critical value)
5. Reject or fail to reject H0
Every hypothesis test, regardless of type, follows this same skeleton.

§ 02The Null and Alternative Hypotheses

The null hypothesis H0 is the default claim: typically one of "no effect," "no difference," or "equal to a specific value." It is the statement we assume true and attempt to disprove. The alternative hypothesis H1 (also written Ha) is what we believe is true if H0 is false.

Null Hypothesis H0

Always contains an equality. Expressed as:

  • μ = μ0 (population mean equals a value)
  • p = p0 (population proportion equals a value)
  • μ1 = μ2 (two means are equal)

Alternative Hypothesis H1

Specifies the direction of the claimed effect:

  • μ ≠ μ0 (two-tailed: any difference)
  • μ > μ0 (right-tailed: mean has increased)
  • μ < μ0 (left-tailed: mean has decreased)

The direction of H1 determines the tail of the test. A two-tailed test splits the significance level equally between both tails; a one-tailed test concentrates it in one tail and is more powerful for detecting the specific direction stated in H1.

Critical Rule Hypotheses must be stated before seeing the data. Writing H1 after examining results to match what you observed is called p-hacking or HARKing (Hypothesising After Results are Known) — a serious violation of statistical integrity.

§ 03Significance Level α and the p-Value

The significance level α is the probability threshold below which we consider the evidence against H0 sufficient to reject it. Common choices are α = 0.05 (5%), α = 0.01 (1%), and α = 0.10 (10%). It is set in advance, before computing any test statistic.

The p-value is the probability of obtaining a test statistic at least as extreme as the one observed, assuming H0 is true. A small p-value means the observed data would be very unlikely under H0, which is evidence against it.

Decision Rule
If p-value ≤ α  →  Reject H0
If p-value > α  →  Fail to reject H0

"Fail to reject" is not the same as "accept." We never prove H0 is true; we only lack sufficient evidence to reject it.

The Critical Value Approach

An equivalent method avoids computing an exact p-value. Instead, find the critical value zα (or tα,ν) that cuts off the rejection region. If the test statistic falls in the rejection region, reject H0. The two approaches always give the same decision.

Two-Tailed, α = 0.05
zcrit = ±1.960 Reject if |z| > 1.960. The 2.5% in each tail gives total 5% rejection region.
One-Tailed (right), α = 0.05
zcrit = +1.645 Reject if z > 1.645. All 5% is in the right tail.
One-Tailed (left), α = 0.05
zcrit = −1.645 Reject if z < −1.645. All 5% is in the left tail.
Two-Tailed, α = 0.01
zcrit = ±2.576 Stricter threshold for higher-stakes decisions. Harder to reject H0.

§ 04Type I and Type II Errors

Hypothesis testing involves two kinds of mistakes. Understanding them is essential for choosing α and interpreting results responsibly.

Error Type What Happened Probability Also Called
Type I (α) Rejected H0 when H0 was actually true (false positive) P(Type I) = α False positive; significance level
Type II (β) Failed to reject H0 when H1 was actually true (false negative) P(Type II) = β False negative; missed detection
Power (1−β) Correctly rejected H0 when H1 was true 1 − β Sensitivity; true positive rate

There is an inherent trade-off: reducing α (making Type I errors less likely) automatically increases β (making Type II errors more likely), for a fixed sample size. The only way to reduce both simultaneously is to increase the sample size n.

Intuition Think of a court trial. H0 is "innocent." A Type I error is convicting an innocent person. A Type II error is acquitting a guilty one. Courts set a high bar for conviction (small α), accepting more Type II errors to protect against Type I.

§ 05The z-Test for a Population Mean

When the population standard deviation σ is known and either the population is normal or n ≥ 30 (by the Central Limit Theorem), use the z-test. The test statistic measures how many standard errors the sample mean x̄ is from the hypothesised mean μ0.

z-Test Statistic
z = (x̄ − μ0) / (σ / √n)
x̄ = sample mean  ·  μ0 = hypothesised mean  ·  σ = known population SD  ·  n = sample size

Under H0, this statistic follows a standard normal distribution Z ∼ N(0,1). You then find the p-value from the z-table and compare to α.

Example 01 Two-tailed z-test — machine fill weight

A machine is set to fill bags to μ = 500 g with σ = 12 g. A sample of n = 36 bags gives x̄ = 495 g. At α = 0.05, is there evidence the machine is mis-calibrated?

Hypotheses
H0: μ = 500    H1: μ ≠ 500  (two-tailed)
Test Stat
z = (495 − 500) / (12 / √36) = −5 / 2 = −2.50
p-value
p = 2 × P(Z < −2.50) = 2 × 0.0062 = 0.0124
Decision

p = 0.0124 < α = 0.05, so we reject H0.

Conclusion
There is significant evidence at the 5% level that the machine is mis-calibrated.
Example 02 Right-tailed z-test — delivery times

A courier claims mean delivery time μ = 3.2 days. Customers suspect it is higher. A sample of n = 50 deliveries gives x̄ = 3.5 days. Population σ = 1.1 days. Test at α = 0.01.

Hypotheses
H0: μ = 3.2    H1: μ > 3.2  (right-tailed)
Test Stat
z = (3.5 − 3.2) / (1.1 / √50) = 0.3 / 0.1556 ≈ 1.93
Critical Value
zcrit = 2.326 for α = 0.01 (right tail)
Decision

z = 1.93 < 2.326, so we fail to reject H0.

Conclusion
Insufficient evidence at 1% to conclude deliveries are slower than claimed.

§ 06The t-Test When σ Is Unknown

In practice, the population standard deviation σ is almost never known. When it must be estimated from the sample using s, the test statistic follows a t-distribution with ν = n − 1 degrees of freedom, not the standard normal. The t-distribution has heavier tails, reflecting the additional uncertainty introduced by estimating σ.

One-Sample t-Test Statistic
t = (x̄ − μ0) / (s / √n)
s = sample standard deviation  ·  degrees of freedom ν = n − 1

As n grows, the t-distribution approaches the standard normal: for n ≥ 30, the difference is practically negligible. For small samples (n < 30), the t-distribution matters considerably.

Example 03 One-sample t-test — student exam scores

A university claims the mean exam score is μ = 68. A lecturer samples n = 16 students and finds x̄ = 72, s = 8. Is there evidence the class mean is higher than claimed? Test at α = 0.05.

Hypotheses
H0: μ = 68    H1: μ > 68  (right-tailed)
Test Stat
t = (72 − 68) / (8 / √16) = 4 / 2 = 2.00
Critical Value
tcrit = t0.05, 15 = 1.753  (15 df, one-tailed)
Decision

t = 2.00 > 1.753, so we reject H0.

Conclusion
Significant evidence at 5% that the class mean exceeds 68.
Example 04 Two-sample t-test — comparing two teaching methods

Group A (n1 = 12): x̄1 = 75, s1 = 6. Group B (n2 = 15): x̄2 = 70, s2 = 7. Test H0: μ1 = μ2 vs H1: μ1 ≠ μ2 at α = 0.05, assuming equal variances.

Pooled SD
sp = √[((12−1)×36 + (15−1)×49) / (12+15−2)] = √(396+686)/25 = √43.28 ≈ 6.58
Test Stat
t = (75−70) / (6.58 √(1/12 + 1/15)) = 5 / (6.58×0.3727) ≈ 5 / 2.452 ≈ 2.04
Critical Value
tcrit = t0.025, 25 = 2.060  (25 df, two-tailed)
Decision
t = 2.04 < 2.060 → Fail to reject H0. No significant difference at 5%.

§ 07Hypothesis Test for a Population Proportion

When the parameter of interest is a proportion p rather than a mean, the test statistic is still a z-statistic, derived from the normal approximation to the binomial. The conditions np0 ≥ 10 and n(1−p0) ≥ 10 must hold.

z-Test for a Proportion
z = (p̂ − p0) / √(p0(1−p0) / n)
p̂ = sample proportion  ·  p0 = hypothesised proportion  ·  n = sample size
Example 05 Proportion test — defective rate

A manufacturer claims at most 4% of products are defective. In a sample of n = 200, 12 are defective (p̂ = 0.06). Test H0: p = 0.04 vs H1: p > 0.04 at α = 0.05.

Check
np0 = 200×0.04 = 8 ≥ 5, n(1−p0) = 192 ≥ 5 ✓
Test Stat
z = (0.06 − 0.04) / √(0.04×0.96/200) = 0.02 / 0.01386 ≈ 1.44
p-value
p = P(Z > 1.44) = 1 − 0.9251 = 0.0749
Decision
p = 0.0749 > 0.05 → Fail to reject H0. Insufficient evidence the defect rate exceeds 4%.
Example 06 Proportion test — election polling

A candidate needs more than 50% of the vote to win. A poll of n = 400 voters finds 210 in favour (p̂ = 0.525). Is there significant evidence the candidate will win? Test at α = 0.05.

Hypotheses
H0: p = 0.50    H1: p > 0.50  (right-tailed)
Test Stat
z = (0.525 − 0.50) / √(0.50×0.50/400) = 0.025 / 0.025 = 1.00
Decision
p-value = P(Z > 1.00) = 0.1587 > 0.05 → Fail to reject H0. No significant evidence the candidate leads.

§ 08One-Tailed vs Two-Tailed Tests

Choosing between one-tailed and two-tailed is a conceptual decision that must be made before the data is collected, based on what effect the researcher is actually interested in detecting.

Two-Tailed
H1: μ ≠ μ0 Use when any deviation from H0 — in either direction — would be meaningful. Critical region is split: α/2 in each tail. Harder to reject but more general.
Right-Tailed
H1: μ > μ0 Use when you specifically suspect the mean has increased. All α is in the right tail. More powerful for detecting increases only.
Left-Tailed
H1: μ < μ0 Use when you specifically suspect the mean has decreased. All α is in the left tail. More powerful for detecting decreases only.
Example 07 Choosing the correct tail — drug side effects

A new drug is tested for its effect on blood pressure. Researchers want to know if it lowers blood pressure (a decrease from μ = 120 mmHg). They observe x̄ = 115 in n = 25 patients with s = 10. Test at α = 0.05.

Hypotheses
H0: μ = 120    H1: μ < 120  (left-tailed)
Test Stat
t = (115 − 120) / (10 / √25) = −5 / 2 = −2.50
Critical Value
tcrit = −t0.05, 24 = −1.711  (left-tailed, 24 df)
Decision
t = −2.50 < −1.711 → Reject H0. Significant evidence the drug lowers blood pressure.

§ 09Further Worked Examples

Example 08 Paired t-test — before and after training

10 employees complete a typing speed test before and after a training course. The mean difference (after − before) is d̄ = 8.5 wpm with sd = 4.2 wpm. Test H0: μd = 0 vs H1: μd > 0 at α = 0.05.

Test Stat
t = d̄ / (sd / √n) = 8.5 / (4.2 / √10) = 8.5 / 1.328 ≈ 6.40
Critical Value
t0.05, 9 = 1.833  (9 df, one-tailed)
Decision
t = 6.40 ≫ 1.833 → Strong evidence the training improved typing speed (p << 0.001).
Example 09 z-test for a proportion — conversion rate

A website historically converts 8% of visitors. After a redesign, 56 out of 600 visitors converted (p̂ = 0.0933). Did the redesign change the rate? Test H0: p = 0.08 vs H1: p ≠ 0.08 at α = 0.05.

Test Stat
z = (0.0933 − 0.08) / √(0.08×0.92/600) = 0.0133 / 0.01109 ≈ 1.20
p-value
p = 2 × P(Z > 1.20) = 2 × 0.1151 = 0.2302
Decision
p = 0.2302 > 0.05 → Fail to reject H0. No significant change in conversion rate.
Example 10 Interpreting p = 0.048 vs p = 0.052

Two researchers test the same hypothesis. One gets p = 0.048, the other gets p = 0.052. With α = 0.05, the first rejects H0 and the second does not. This illustrates an important point about the threshold.

Insight

The difference between p = 0.048 and p = 0.052 is trivially small, no meaningful distinction in the strength of evidence. Yet the binary reject/fail-to-reject outcome differs. This is a known weakness of rigid α-thresholds.

Best Practice

Always report the exact p-value alongside the decision. "p = 0.052, fail to reject at α = 0.05" conveys far more than simply "not significant." Effect size and confidence intervals should accompany hypothesis tests.

Key Takeaway
Statistical significance is a threshold, not a measure of importance. Always report p exactly.

§ 10Common Mistakes and Misconceptions

Misreading the p-value
p ≠ P(H0 is true) The p-value is P(data this extreme | H0 true). It says nothing directly about how probable H0 itself is. This is the most common misconception.
"Accepting" H0
Only ever "fail to reject" A large p-value means weak evidence against H0, not proof that H0 is correct. Absence of evidence is not evidence of absence.
Multiple Testing
k tests → αeff rises Run 20 tests at α = 0.05 and expect roughly one false rejection by chance alone. Use Bonferroni correction (α/k) or FDR control for multiple comparisons.
Wrong tail
Decide before seeing data Switching from two-tailed to one-tailed after seeing which way the data points halves the effective α and inflates Type I error. The tail must be chosen from theory, not results.
Ignoring Effect Size
Significant ≠ Important With large n, even a trivially small difference can be statistically significant. Always report Cohen's d or a confidence interval alongside the test result.
Using z when t is needed
Unknown σ → use t Replacing σ with s in a z-test underestimates the true variability, making the test anti-conservative. Always use the t-distribution when σ is estimated.

§ 11The Duality with Confidence Intervals

Hypothesis testing and confidence intervals are two sides of the same coin. A two-tailed test at significance level α rejects H0: μ = μ0 if and only if μ0 falls outside the corresponding (1−α)×100% confidence interval.

The Duality Theorem
Reject H0: μ = μ0 at α  ⇔  μ0 ∉ CI1−α

Both approaches yield identical decisions for two-tailed tests. Confidence intervals carry more information, since they show the plausible range of parameter values, not just a binary decision.

Practical Advice Whenever you perform a hypothesis test, compute and report the corresponding confidence interval as well. The interval communicates both the statistical significance and the practical magnitude of the result, making it far more informative for a reader.

Continue the Statistics Series

§ 12Quiz — Test Your Understanding

Ten questions covering all aspects of hypothesis testing. Immediate feedback on each answer.

Hypothesis Testing Quiz

Question 1 of 10
The null hypothesis H0 always contains…
Question 2 of 10
A p-value of 0.03 means that, assuming H0 is true, the probability of observing data at least this extreme is…
Question 3 of 10
You test H0: μ = 50 vs H1: μ ≠ 50 at α = 0.05. You compute z = −2.10. What do you conclude?
Question 4 of 10
A Type I error occurs when…
Question 5 of 10
A sample of n = 25 gives x̄ = 48 and s = 10. Testing H0: μ = 50 (two-tailed). What is the t-statistic?
Question 6 of 10
Which test statistic should you use when σ is unknown and n = 18?
Question 7 of 10
A researcher runs 20 independent hypothesis tests, each at α = 0.05. Approximately how many false rejections (Type I errors) should she expect if all null hypotheses are true?
Question 8 of 10
For a right-tailed z-test at α = 0.05, the critical value is…
Question 9 of 10
A 95% confidence interval for μ is (42, 58). A researcher tests H0: μ = 60 at α = 0.05 (two-tailed). Without any calculation, what is the decision?
Question 10 of 10
Increasing the sample size n, while keeping α fixed, will…
0 out of 10

Cookie Settings