Home / Articles / Probability & Statistics
Probability & Statistics · 5 min read

Hypothesis Testing for Beginners

Learn hypothesis testing step by step: null and alternative hypotheses, test statistics, p-values and critical values, with two fully worked examples.

Hypothesis testing is how statisticians decide whether a pattern in sample data is real or just the result of random chance. Once you understand the logic, every test you meet, whether z, t or chi-square, follows the same five steps. This guide walks you through that logic and then puts it to work on two full examples.

The Big Idea

Imagine a company claims its packets of biscuits weigh 500 g on average. You weigh a sample and get a mean of 495.8 g. Is the company lying, or is a 4.2 g shortfall just normal sampling variation? Hypothesis testing gives a disciplined way to answer this.

We start by assuming the claim is true, then ask: if it were true, how surprising would our sample be? If the sample would be very surprising, we reject the claim.

Key Terms

  • Null hypothesis \( H_0 \): the "no change" or "status quo" statement, for example \( \mu = 500 \).
  • Alternative hypothesis \( H_1 \): what you suspect instead, for example \( \mu \neq 500 \), \( \mu < 500 \) or \( \mu > 500 \).
  • Significance level \( \alpha \): the risk of wrongly rejecting a true \( H_0 \) you are willing to accept. Common choices are 0.05 and 0.01.
  • Test statistic: a number (such as \( z \) or \( t \)) measuring how far the sample result is from what \( H_0 \) predicts.
  • p-value: the probability, assuming \( H_0 \) is true, of getting a result at least as extreme as the one observed.
  • Critical value: the boundary of the rejection region for a given \( \alpha \).

One-Tailed vs Two-Tailed Tests

If \( H_1 \) uses \( \neq \), the test is two-tailed: extreme results in either direction count as evidence. If \( H_1 \) uses \( < \) or \( > \), the test is one-tailed, and only one direction counts. Decide this before looking at the data.

The Five-Step Procedure

  1. State \( H_0 \) and \( H_1 \).
  2. Choose the significance level \( \alpha \).
  3. Calculate the test statistic.
  4. Find the p-value or the critical value.
  5. Make a decision and write a conclusion in context.

Which Test Statistic?

For a population mean:

  • If the population standard deviation \( \sigma \) is known (or \( n \) is large), use the z-test:

$$ z = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}} $$

  • If \( \sigma \) is unknown and you use the sample standard deviation \( s \), use the t-test with \( n - 1 \) degrees of freedom:

$$ t = \frac{\bar{x} - \mu_0}{s / \sqrt{n}} $$

Worked Example 1: Two-Tailed z-Test

A factory claims biscuit packets have mean weight 500 g, with known \( \sigma = 12 \) g. A sample of \( n = 36 \) packets has mean \( \bar{x} = 495.8 \) g. Test the claim at \( \alpha = 0.05 \).

Step 1: Hypotheses.

$$ H_0: \mu = 500 \qquad H_1: \mu \neq 500 $$

Step 2: Significance level. \( \alpha = 0.05 \), two-tailed, so the critical values are \( z = \pm 1.96 \).

Step 3: Test statistic. First find the standard error:

$$ \frac{\sigma}{\sqrt{n}} = \frac{12}{\sqrt{36}} = \frac{12}{6} = 2 $$

Then

$$ z = \frac{495.8 - 500}{2} = \frac{-4.2}{2} = -2.1 $$

Step 4: p-value. From the standard normal table, \( P(Z < -2.1) \approx 0.0179 \). Because the test is two-tailed, double it:

$$ p = 2 \times 0.0179 = 0.0358 $$

Step 5: Decision. Since \( p = 0.0358 < 0.05 \) (equivalently, \( -2.1 < -1.96 \)), we reject \( H_0 \).

Conclusion: At the 5% level, there is sufficient evidence that the mean packet weight differs from 500 g. Note that at \( \alpha = 0.01 \) we would not reject, because \( 0.0358 > 0.01 \). The choice of \( \alpha \) matters.

Worked Example 2: One-Tailed t-Test

A teacher believes a new revision method raises the average score above 50. A sample of \( n = 16 \) students scores \( \bar{x} = 52 \) with sample standard deviation \( s = 6 \). Test at \( \alpha = 0.05 \).

Step 1: Hypotheses.

$$ H_0: \mu = 50 \qquad H_1: \mu > 50 $$

Step 2: Significance level. \( \alpha = 0.05 \), one-tailed (right). Degrees of freedom \( = 16 - 1 = 15 \). From t-tables, the critical value is \( t_{0.05,\,15} = 1.753 \).

Step 3: Test statistic.

$$ \frac{s}{\sqrt{n}} = \frac{6}{\sqrt{16}} = \frac{6}{4} = 1.5 $$

$$ t = \frac{52 - 50}{1.5} = \frac{2}{1.5} \approx 1.333 $$

Step 4: Compare. \( 1.333 < 1.753 \), so the statistic does not fall in the rejection region.

Step 5: Decision. We fail to reject \( H_0 \).

Conclusion: At the 5% level, there is not enough evidence that the new method raises the mean score above 50. The sample average was higher, but with only 16 students the difference could easily be due to chance. A larger sample might give a different answer.

Type I and Type II Errors

No test is perfect. Two kinds of mistake are possible:

  • Type I error: rejecting \( H_0 \) when it is actually true. Its probability is \( \alpha \).
  • Type II error: failing to reject \( H_0 \) when it is actually false. Its probability is called \( \beta \), and \( 1 - \beta \) is the power of the test.

Lowering \( \alpha \) reduces Type I errors but increases Type II errors, unless you also increase the sample size.

Common Mistakes

  • Saying "accept \( H_0 \)". We only fail to reject it. Absence of evidence is not proof that \( H_0 \) is true.
  • Misreading the p-value. A p-value of 0.03 does not mean there is a 3% chance \( H_0 \) is true. It is the probability of data this extreme if \( H_0 \) were true.
  • Forgetting to double for two-tailed tests. Look up one tail, then multiply by 2.
  • Using z when you should use t. If \( \sigma \) is unknown and the sample is small, use the t-distribution.
  • Choosing the tail after seeing the data. This inflates the Type I error rate.
  • Skipping the context. Always end with a sentence about the real situation, not just "reject \( H_0 \)".

Key Takeaways

  • Every hypothesis test assumes \( H_0 \) is true and asks how surprising the sample is.
  • Follow the five steps: hypotheses, \( \alpha \), test statistic, p-value or critical value, conclusion.
  • Reject \( H_0 \) when \( p < \alpha \) or when the statistic falls in the rejection region.
  • Use the z-test when \( \sigma \) is known and the t-test with \( n-1 \) degrees of freedom when it is not.
  • "Fail to reject" is not the same as "prove true".

Stuck on a statistics assignment or a tricky test question? Send it to Amathify on WhatsApp or through the "Ask a Question" form, and our subject experts and PhD scholars will return a clear, step-by-step solution.

Stuck on a problem or assignment?

Our experts and PhD scholars solve maths, physics and chemistry — step by step.

WhatsApp usAsk a question

Related articles