WhatsApp us
University Maths25 Nov 2026

Hypothesis Testing Steps With Examples: z-Test, t-Test and Chi-Square

The seven steps of a hypothesis test, applied to five original examples (a z-test, a one-sample t-test, a paired t-test and two chi-square tests), with a test-choice table and the slips that cost marks.

Hypothesis Testing Steps With Examples: z-Test, t-Test and Chi-Square

A hypothesis test has seven steps: state the null and alternative hypotheses, choose the significance level, choose the test and check its assumptions, compute the test statistic, find the p-value or critical value, make the decision, and write the conclusion in the context of the question. The arithmetic changes from test to test, but those steps do not, and most lost marks come from skipping one of them rather than from the calculation.

Below, each step is explained once, then applied to five examples of the tests that appear most in first statistics courses. The data are our own and every statistic and p-value has been checked by calculation.

The seven steps in detail

  1. Hypotheses. H₀ is the "no effect" statement with an equals sign: μ = 205, or "the variables are independent". H₁ is what you are looking for evidence of: μ ≠ 205 (two-sided), μ > 205 or μ < 205 (one-sided). Decide the direction from the question's wording before you look at the data.
  2. Significance level α. Usually 5%, sometimes 1% or 10%. It is the probability of rejecting H₀ when H₀ is true (a Type I error).
  3. Test and assumptions. Pick the test from the table below and say why. A t-test assumes roughly normal data or a reasonably large sample; a chi-square test needs every expected count to be at least about 5.
  4. Test statistic. Compute z, t or χ² with the formula for that test.
  5. p-value or critical value. Either method is fine; use the one your course uses. The p-value is the probability, if H₀ were true, of a result at least as extreme as the one observed.
  6. Decision. Reject H₀ if p < α, or if the statistic is beyond the critical value. Otherwise "do not reject H₀". Never "accept H₀".
  7. Conclusion in context. One sentence in the language of the problem: "There is evidence at the 5% level that the mean response time exceeds 205 ms."

If your module's tests are piling up, our online probability and statistics tutoring page explains how sessions with Ajay Vatsyayan work.

Which test to use

SituationTestStatisticDegrees of freedom
one mean, σ known (or very large n)z-testz = (x̄ − μ₀)/(σ/√n)none
one mean, σ unknownone-sample t-testt = (x̄ − μ₀)/(s/√n)n − 1
same subjects measured twicepaired t-testt = d̄/(s_d/√n) on the differencesn − 1
two independent groupstwo-sample t-testdifference of means over its standard errordepends on the version
counts in categories vs a claimed distributionchi-square goodness of fitχ² = ∑ (O − E)²/Ecategories − 1 − estimated parameters
two categorical variables in a tablechi-square independenceχ² = ∑ (O − E)²/E(rows − 1)(columns − 1)

Two quick tests of recognition: if the data are numbers you can average, you want z or t; if they are counts in categories, you want chi-square. If the same item appears in both samples, the test is paired.

Example 1: a z-test for a filling machine

A machine fills bags with a target mean of 500 g. The fill weight has known standard deviation 6 g. A sample of 36 bags has mean 497.8 g. Test at the 5% level whether the machine's mean has moved.

  1. H₀: μ = 500, H₁: μ ≠ 500 ("moved" means either direction).
  2. α = 0.05, two-sided.
  3. σ is known and n = 36, so a z-test.
  4. z = (497.8 − 500)/(6/√36) = −2.2/1 = −2.20
  5. p = 2 × P(Z < −2.20) = 0.0278. The critical values are ±1.96.
  6. p < 0.05 (and −2.20 < −1.96), so reject H₀.
  7. There is evidence at the 5% level that the mean fill weight is no longer 500 g.

At the 1% level (critical values ±2.576) you would not reject. Always quote the level with the conclusion.

Example 2: a one-sample t-test on response times

A server's mean response time is claimed to be 205 ms. Ten requests give times (ms): 212, 198, 225, 207, 219, 230, 201, 215, 222, 209. Test at 5% whether the mean is greater than 205 ms.

  1. H₀: μ = 205, H₁: μ > 205.
  2. α = 0.05, one-sided.
  3. σ unknown, small sample, so a t-test with 9 degrees of freedom, assuming response times are roughly normal.
  4. The sum is 2138, so x̄ = 213.8. The sum of squared deviations is 969.6, so s² = 969.6/9 = 107.73 and s = 10.38. Then t = (213.8 − 205)/(10.38/√10) = 8.8/3.282 = 2.681.
  5. The one-sided critical value for t with 9 df is 1.833; the p-value is 0.0126.
  6. 2.681 > 1.833, so reject H₀.
  7. There is evidence at the 5% level that the mean response time exceeds 205 ms.

The most common slip here is dividing by n instead of n − 1 when computing s. With n = 10 that changes s from 10.38 to 9.85 and inflates t.

Example 3: a paired t-test on a process change

Eight machines are timed (seconds per cycle) before and after a software update.

Machine12345678
before6874598177637066
after6570607672616664
difference d34−155242

Test at 5% whether the update changed the mean cycle time.

  1. H₀: μ_d = 0, H₁: μ_d ≠ 0, where d = before − after.
  2. α = 0.05, two-sided.
  3. The same machines are measured twice, so a paired t-test on the differences, df = 7.
  4. d̄ = 24/8 = 3. The squared deviations from 3 add to 28, so s_d² = 28/7 = 4 and s_d = 2. Then t = 3/(2/√8) = 4.243.
  5. The two-sided critical value with 7 df is 2.365; p = 0.0038.
  6. Reject H₀.
  7. There is strong evidence that the update changed the mean cycle time; on average it fell by 3 seconds.

Treating these as two independent samples would be a modelling error: the large machine-to-machine variation would swamp the 3-second effect. Pairing removes it.

Example 4: chi-square goodness of fit for a die

A die is rolled 120 times with counts 14, 22, 17, 25, 18, 24 for faces 1 to 6. Test at 5% whether it is fair.

  1. H₀: each face has probability 1/6. H₁: the die is not fair.
  2. α = 0.05.
  3. Expected counts are 120/6 = 20 each, all at least 5, so a chi-square goodness-of-fit test with 6 − 1 = 5 df.
  4. χ² = (36 + 4 + 9 + 25 + 4 + 16)/20 = 94/20 = 4.70
  5. The critical value with 5 df is 11.07; p = 0.454.
  6. 4.70 < 11.07, so do not reject H₀.
  7. There is no evidence at the 5% level that the die is biased.

"No evidence of bias" is not the same as "the die is fair". With 120 rolls the test can only detect fairly large biases.

Example 5: chi-square test of independence

A plant records 120 defects by shift and type.

ShiftScratchDentMisalignmentTotal
day34161060
night16242060
total504030120

Test at 5% whether defect type is independent of shift.

  1. H₀: type and shift are independent. H₁: they are associated.
  2. α = 0.05.
  3. Expected count = row total × column total ÷ grand total. Each row's expected counts are 60 × 50/120 = 25, 60 × 40/120 = 20 and 60 × 30/120 = 15, all at least 5. df = (2 − 1)(3 − 1) = 2.
  4. Day row: (34 − 25)²/25 + (16 − 20)²/20 + (10 − 15)²/15 = 3.24 + 0.80 + 1.667. The night row gives the same three values. Total χ² = 11.41.
  5. The critical value with 2 df is 5.991; p = 0.0033.
  6. Reject H₀.
  7. There is evidence that defect type depends on shift: scratches are more common on the day shift.

Where students lose marks

  • Hypotheses written about the sample. H₀: x̄ = 205 is wrong; hypotheses are about the population parameter μ.
  • Choosing the direction after seeing the data. Decide one- or two-sided from the wording, before calculating.
  • "Accept H₀". You can only fail to reject it. Examiners often deduct for this wording.
  • Using n instead of n − 1 for the sample standard deviation, or for t degrees of freedom.
  • Unpaired test on paired data, as example 3 warns.
  • Chi-square on percentages. Use the observed counts, never proportions or percentages.
  • Wrong df for chi-square independence. It is (r − 1)(c − 1), not rc − 1.
  • Reading p as the probability H₀ is true. It is the probability of data this extreme if H₀ is true. That is Bayes territory; see our Bayes' theorem examples for the difference.

Practice set

  1. A process has σ = 0.5 and a target mean 12.0. A sample of 25 gives x̄ = 12.18. Test at 5% (two-sided).
  2. A sample of 16 has x̄ = 52.4 and s = 4.0. Test H₀: μ = 50 against H₁: μ > 50 at 5%.
  3. A four-sector spinner is spun 200 times: 41, 58, 47, 54. Test at 5% whether the sectors are equally likely.
  4. Method A: 45 pass, 15 fail. Method B: 30 pass, 30 fail. Test at 5% whether outcome is independent of method (no continuity correction).
  5. A test gives p = 0.03. What is the decision at the 1% level, and why?

Answers. (1) z = 1.80, p = 0.072: do not reject. (2) t = 2.40 with 15 df, critical value 1.753, p = 0.015: reject. (3) χ² = 3.40 with 3 df, critical value 7.815: do not reject. (4) Expected counts 37.5 and 22.5 in each row, χ² = 8.00 with 1 df, critical value 3.841: reject. (5) Do not reject, because 0.03 > 0.01.

What comes after these tests

The same logic carries into confidence intervals (which are tests turned inside out), two-sample and Welch t-tests, analysis of variance (ANOVA), regression coefficient tests, non-parametric tests such as Wilcoxon, and A/B testing in industry. The normal and t-distributions behind these tests rest on the models in our guide to binomial, Poisson and normal distributions. If you studied tests at school, compare with the IB hypothesis tests guide and the IB tests and confidence intervals guide.

How Maths Bodhi helps

We work through your own module's data sets and past papers, check each of the seven steps in your written answers, and practise test choice until it is automatic. Engineering students can see our engineering mathematics sessions, and other courses are on our university maths hub. We explain, practise and review your own attempts; we don't complete graded assignments, quizzes or exams. Home tuition is available in Gurgaon (Gurugram). Students elsewhere in India and abroad learn with us online. You can book a free demo class.

Written and checked by the Maths Bodhi team (November 2026).

Frequently asked questions

What are the steps of hypothesis testing?
State H₀ and H₁, choose α, choose the test and check assumptions, compute the statistic, find the p-value or critical value, decide, and conclude in context.
When do I use a t-test instead of a z-test?
Use a t-test when the population standard deviation is unknown and estimated by the sample standard deviation s.
What is the difference between a paired and an unpaired t-test?
A paired test uses differences from the same subjects measured twice; an unpaired test compares two independent groups.
How do I calculate degrees of freedom for a chi-square test?
Goodness of fit: categories minus 1 (minus any estimated parameters); independence: (rows − 1)(columns − 1).
What does a p-value of 0.03 mean?
If H₀ were true, a result at least this extreme would happen about 3% of the time; it is not the probability that H₀ is true.
Why do we say "fail to reject" instead of "accept" the null hypothesis?
Not finding evidence against H₀ does not show it is true; the sample may be too small to detect a real effect.
hypothesis testingt-testchi-square teststatisticsuniversity maths

Related guides

Keep exploring this maths topic

IB DP Maths25 Nov 2026

Proof in IB Maths: Deduction, Counterexamples, Contradiction and Necessary vs Sufficient Conditions

Where proof sits in IB maths AA SL and HL, how to read "if", "only if" and "if and only if", necessary versus sufficient conditions with calculus and algebra examples, LHS to RHS proofs, counterexamples, proof by contradiction and a short look at induction. Worked examples plus a six-question practice set with answers.

IB maths proofnecessary and sufficient conditionsproof by contradictioncounterexample IB maths

By Maths Bodhi Team

Read guide

IB DP Maths25 Nov 2026

IB Maths Problem-Solving Strategies: 7 Ways to Crack Unfamiliar Questions

Seven problem-solving strategies for the unfamiliar parts of IB maths questions, each with a fully worked AA or AI example: breaking a question into parts, small cases, changing the representation, symmetry, invariants, boundary cases and spotting hidden structure.

IB maths problem solvingunfamiliar IB maths questionsIB maths Paper 3 strategiesIB maths AA HL

By Maths Bodhi Team

Read guide

IB DP Maths25 Nov 2026

IB Maths for Economics, Business, Data Science and Engineering: The Skills Each Degree Uses

Which IB maths topics economics, business, data science and engineering degrees actually build on, shown with worked examples from AA and AI: marginal cost, compound growth, expected value, regression, matrices, conditional probability, kinematics and differential equations. Plus a Year 1 plan and the mistakes families make.

IB maths for economicsIB maths for engineeringIB maths for data scienceis IB maths useful

By Maths Bodhi Team

Read guide