Hypothesis testing AI SL
A hypothesis test asks whether sample data give enough evidence against an assumption. This course has two named tests: the chi-squared test, for counts in categories, and the t-test, for comparing the means of two groups. In both the calculator finds the test statistic and the p-value, so the marks are for stating the hypotheses in words, choosing the right test and tail, comparing the p-value with the significance level, and writing the conclusion in the context of the question.
Formulas at a glance
The booklet gives the formula for the chi-squared statistic, but in the examination the statistic and the p-value come from the calculator, so no formula is needed to carry out either test. The rule for degrees of freedom and the decision rule (reject the null hypothesis when the p-value is less than the significance level, or when the chi-squared statistic is greater than the critical value) are not in the booklet, so learn them.
Degrees of freedom for an contingency table
Not in the bookletDecision rule by p-value
Reject if significance level
Not in the bookletDecision rule by critical value
Reject if
Not in the bookletValidity condition for the test
Expected frequency in every cell
Not in the bookletWhich method to use
Decide what kind of data there is before anything else. Counts in categories lead to a chi-squared test, and two groups of measurements whose means are being compared lead to a t-test.
| The question has | Use | Notes |
|---|---|---|
| Two categorical variables and a table of counts, asking whether they are associated | The chi-squared test for independence | The null hypothesis says the variables are independent; the degrees of freedom are (rows - 1)(columns - 1) |
| Observed counts compared with a stated model, such as a fair die or equal numbers each day | The chi-squared goodness of fit test | The null hypothesis says the data fit the model; the degrees of freedom are the number of categories minus 1 |
| A p-value and a significance level | Reject the null hypothesis if is less than the significance level | Compare the two numbers, then give the conclusion in context |
| A chi-squared statistic and a critical value | Reject the null hypothesis if the statistic is greater than the critical value | Only upper-tail chi-squared tests are set |
| Two groups of measurements, and a question about their means | The two-sample t-test, with the pooled option on | The two samples are unpaired, and the variances of the two groups are assumed equal |
| The words "different from", "greater than" or "less than" about a mean | A two-tailed test for "different", a one-tailed test for a direction | Choose the alternative hypothesis on the calculator to match the claim |
| A conclusion to write | Compare, say reject or do not reject the null hypothesis, then say what it means in context | "Do not reject" never means the null hypothesis has been proved |
Section 1 of 2 SL4.11
Chi-squared test
The test compares observed frequencies with the frequencies expected if the null hypothesis is true. The test for independence uses a contingency table to decide whether two categorical variables are associated, and the goodness-of-fit test checks whether data matches a stated distribution. Your GDC gives the test statistic and -value, or you compare the statistic with a critical value.
Degrees of freedom and expected frequency
Degrees of freedom
This is for the test for independence on a contingency table. A goodness-of-fit test instead uses .
Expected frequency
Expected frequency in every cell - this is not in the formula booklet, it's a syllabus requirement for the approximation to be valid.
Key terms
What is a contingency table?
A contingency table shows observed frequencies, with the categories of one variable in the rows and the categories of the other in the columns, plus totals.
e.g. A table with rows and columns has cells, so expected frequencies must be found.
What are observed and expected frequencies?
Observed frequencies are the counts actually recorded. Expected frequencies are the counts you would get if the null hypothesis were true.
e.g. If a die is rolled times and is fair, the expected frequency of each face is .
What does the test statistic measure?
It measures how far the observed frequencies are from the expected frequencies. A larger value means a bigger difference and less support for the null hypothesis.
e.g. If every observed frequency equals its expected frequency, the test statistic is .
What is a critical value?
The critical value is a number from the distribution that depends on the degrees of freedom and the significance level. If the test statistic is greater than it, reject .
e.g. With degrees of freedom at the 5% level the critical value is , so a test statistic of is greater and is rejected.
Worked example, step by step
The question Calculator needed [6 marks]
A council asks 150 residents how they usually travel to the town centre and records each resident's age band. The results are:
Under 40: 24 walk, 18 go by bus and 33 go by car.
40 and over: 12 walk, 30 go by bus and 33 go by car.
A chi-squared test for independence is carried out at the 5% significance level.
(a) State the null hypothesis and the alternative hypothesis.
(b) Use your calculator to find the chi-squared statistic and the -value.
(c) State the conclusion of the test, in context.
Worked solution: worked example
Answer: (a) : travel method and age band are independent; : they are not independent. (b) , (c) , so reject : there is evidence of an association between travel method and age band.
Step 1 - Decide that a chi-squared test fits.
The data are counts of residents in categories (travel method and age band), set out in a table, and the question is whether the two variables are associated. That is a chi-squared test for independence. The table has 2 rows and 3 columns, so the degrees of freedom are .
Why? Counts in categories point to chi-squared, whereas measurements such as times or masses point to a t-test. The degrees of freedom are needed to check the calculator output and to look up a critical value if one is given.
Step 2 - (a) State the hypotheses in words.
: travel method and age band are independent. : travel method and age band are not independent (they are associated). A1 - : travel method and age band are independent A1 - : travel method and age band are not independent (or are associated)
Why? The null hypothesis is the "no association" statement. Hypotheses are about the population of residents, not about these 150 people, and they are written in words for a test of independence.
Step 3 - (b) Enter the table and run the test.
Enter the observed counts in a matrix with 2 rows and 3 columns, then run the chi-squared test for independence. The calculator gives the expected counts as well. Here they are in both rows. Every expected count is greater than 5, so the test can be used. The calculator output is A1 - A1 -
Why? The calculator carries out the sum of for you, so the working to show is the set-up. Checking that the smallest expected count is above 5 and that matches your own count shows the table was entered correctly.
Step 4 - (c) Compare the p-value with the significance level.
The significance level is 5%, which is 0.05. Since , the null hypothesis is rejected. R1 - Comparison of with 0.05, or of with a critical value
Why? A small p-value means data like these would be unlikely if the variables were independent. The decision rule is to reject when is less than the significance level.
Step 5 - (c) Write the conclusion in context.
There is evidence, at the 5% significance level, that travel method and age band are associated. At the 1% level the same p-value would not be enough to reject , because . A1 - Reject and conclude in context that there is evidence of an association between travel method and age band
Why? A conclusion must refer to the situation in words, not just say "reject ". It also says the association is supported by the data, not proved, and the answer depends on the significance level chosen.
A1 : travel method and age band are independent
A1 : travel method and age band are not independent (or are associated)
A1
A1
R1 Comparison of with 0.05, or of with a critical value
A1 Reject and conclude in context that there is evidence of an association between travel method and age band
Now you try: enter your answers to be marked
These are real practice questions. Type your answer in each box and press Mark it. The worked solution and mark scheme appear straight away, and your first attempt is the one that counts. Use the keyboard for powers, roots and trig, and the working box for your notes.
Worked solution: practice question 1
| Healthy | Balanced | Poor | |
|---|---|---|---|
| Exercise: yes | 30 | 25 | 10 |
| Exercise: no | 15 | 20 | 20 |
Worked solution: practice question 2
| Action | Comedy | Drama | |
|---|---|---|---|
| Under 30 | 40 | 30 | 10 |
| 30-60 | 25 | 35 | 20 |
| Over 60 | 10 | 15 | 15 |
Worked solution: practice question 3
Your score so far: 0 out of 16 marks
Calculator steps: Chi-squared test (goodness of fit & independence), Interpret p-values and significance levels
Common mistakes
- Treating "reject " as proof that is true. A hypothesis test only measures the strength of evidence at a chosen significance level - it never proves anything with certainty, in either direction.
- Forgetting the expected-frequency rule (greater than 5). If any cell's expected frequency is 5 or below, the approximation becomes unreliable - categories should be combined first.
- Using the wrong degrees-of-freedom formula. is for the test for independence on a contingency table; a goodness-of-fit test uses instead. Mixing the two up gives the wrong critical value and the wrong -value.
Section 2 of 2 SL4.11
t-test
A -test uses sample data to judge whether the means of two populations differ. In the examination the two samples are unpaired and the variances of the two groups are assumed equal. State and , read the -value from your GDC, compare it with the significance level, and conclude in context. The test can be one-tailed or two-tailed.
Key terms
What are the null and alternative hypotheses?
The null hypothesis says there is no difference, for example that two population means are equal. The alternative hypothesis states the difference being tested. Both are written about the population means and .
e.g. To test whether the mean mass of packets from two machines differs, write and .
What is a significance level?
The significance level is the threshold, such as 5%, that the -value is compared with. A -value below the threshold leads to rejecting .
e.g. With a significance level of , a -value of is smaller than , so is rejected.
What is a -value?
The -value is the probability of getting a result at least as extreme as the one observed, assuming is true.
e.g. A -value of means that if were true, there would be about a 3% chance of data at least this extreme.
How do you write the conclusion of a hypothesis test?
Compare the -value with the significance level, state whether you reject or do not reject , then say what this means in context. Do not say that is proved.
e.g. With and a significance level of , do not reject : there is insufficient evidence at the 5% level that the two mean times differ.
Worked example, step by step
The question Calculator needed [6 marks]
A teacher compares the time taken to solve a logic puzzle on paper with the time taken to solve it in an app. The times, in seconds, of two independent groups of students are:
Paper (8 students): 48, 52, 45, 50, 55, 47, 51, 49
App (9 students): 46, 47, 43, 49, 45, 44, 48, 51, 43
Both sets of times can be assumed to come from normal distributions with the same variance. The teacher believes that students are quicker with the app. A t-test is carried out at the 5% significance level.
(a) State the null hypothesis and the alternative hypothesis.
(b) Use your calculator to find the -value.
(c) State the conclusion of the test, in context.
Worked solution: worked example
Answer: (a) , (b) (c) , so reject : there is evidence that the mean time is shorter with the app.
Step 1 - Decide which t-test is needed.
There are two separate groups of students, so the samples are unpaired, and the question says to assume equal variances. So a two-sample t-test with the pooled option is used. Let be the mean time on paper and the mean time with the app.
Why? The syllabus uses the unpaired two-sample t-test, with equal variances assumed, so the pooled option is switched on. The means are written for the populations of all such students, not for these 17 students.
Step 2 - (a) Write the hypotheses to match the claim.
: the mean time on paper equals the mean time with the app, . : the mean time on paper is greater than the mean time with the app, . A1 - A1 -
Why? The teacher believes the app is quicker, so the claim has a direction and the test is one-tailed. A quicker app means a shorter time, so the paper mean is the greater one.
Step 3 - (b) Enter the data and set up the test.
Enter the paper times in one list and the app times in a second list. Choose the two-sample t-test using data, with the first list as sample 1 and the second as sample 2. Choose the alternative to match , and set the pooled option to Yes.
Why? The tail on the calculator has to match . The pooled setting matters because the unpooled test uses a different formula and gives a different p-value.
Step 4 - (b) Read the p-value.
The calculator gives , and The degrees of freedom are . A1 - Calculator p-value from the pooled two-sample t-test (unrounded) A1 - to 3 significant figures
Why? Only the p-value is needed for the decision. Checking that shows that both lists were entered in full.
Step 5 - (c) Compare and conclude in context.
Since , reject . There is evidence, at the 5% significance level, that the mean time to solve the puzzle is shorter with the app than on paper. At the 1% level the conclusion would be different, because . R1 - Comparison of with 0.05 A1 - Reject ; evidence that the mean time is shorter with the app
Why? The conclusion must use the context, here quicker with the app. It also supports the teacher's belief rather than proving it, and the decision depends on the significance level.
A1
A1
A1 Calculator p-value from the pooled two-sample t-test (unrounded)
A1 to 3 significant figures
R1 Comparison of with 0.05
A1 Reject ; evidence that the mean time is shorter with the app
Now you try: enter your answers to be marked
Worked solution: practice question 1
Worked solution: practice question 2
State .
Worked solution: practice question 3
Your score so far: 0 out of 6 marks
Calculator steps: Two-sample t-test (comparing two means), Interpret p-values and significance levels
Common mistakes
- Treating "reject " as proof that is true. A hypothesis test only measures the strength of evidence at a chosen significance level - it never proves anything with certainty, in either direction.
- Choosing the wrong tail. "Different from" or "changed" means a two-tailed with ; "increases", "decreases", "is greater/less than" means a one-tailed with or . Missing this changes which -value the GDC should be comparing against .
- Writing hypotheses about and instead of and . and are statements about the population means and , not the particular sample means you happened to calculate.
Using your GDC
The exact key presses for the TI-84 Plus CE, Casio fx-CG50, Casio fx-CG100 and TI-Nspire CX, with what the screen shows. Pick your calculator.
Chi-squared test (goodness of fit & independence)
Used in: Chi-squared test
How to do a chi-squared test on a TI-84 Plus CE
Test of independence (two-way table) | |
Put the observed counts in a matrix. Press 2nd x⁻¹ (MATRIX), press ▶ to reach EDIT, choose 1:[A] and press enter. Type the size, 2 enter 3 enter for 2 rows and 3 columns, then type the counts row by row, pressing enter after each one. |
MATRIX[A] 2 ×3 22 31 17 38 19 13 |
Press 2nd mode (QUIT) to leave the editor. Press stat, press ▶ twice to reach TESTS, and scroll down to C:χ²-Test.... Press enter. |
|
Leave Observed as [A] and Expected as [B]: the calculator stores the expected counts in [B] for you. Move down to Calculate and press enter. , and . |
χ²-Test χ²=7.68 p=0.0214936 df=2 |
To see the expected counts, press 2nd x⁻¹ (MATRIX), choose 2:[B] from the NAMES list and press enter twice. Every expected count should be greater than 5. |
[B] 30 25 15 30 25 15 |
Goodness of fit (observed and expected lists) | |
Press stat, choose 1:Edit and press enter. Type the observed counts 4,6,17,16,8,9 in L1, and the expected counts, 10 six times, in L2, pressing enter after each value. |
L1 L2 4 10 6 10 17 10 16 10 8 10 9 10 |
Press stat, press ▶ twice to reach TESTS, and scroll down to D:χ²GOF-Test.... Press enter. |
|
Set Observed to L1 (press 2nd 1) and Expected to L2 (press 2nd 2). Type the degrees of freedom, 5, because there are 6 categories. Move down to Calculate and press enter. , and . |
χ²GOF-Test χ²=14.2 p=0.01438768 df=5 |
The goodness-of-fit test does not work out df for you: type the number of categories minus 1.
The full guide: Chi-squared test (goodness of fit & independence)
Two-sample t-test (comparing two means)
Used in: t-test
How to do a two-sample t-test on a TI-84 Plus CE
Data in two lists, then 2-SampTTest with Pooled set to Yes | |
Press stat and choose 1:Edit.... Type the values of the first sample in L1 and the values of the second sample in L2, pressing enter after each. The two lists do not need the same number of values. |
L1 L2 72 64 65 70 78 61 81 68 69 59 74 66 77 72 70 63 67 |
Press stat, press ▶ twice to reach TESTS and choose 4:2-SampTTest.... |
|
Set Inpt to Data. Set List1 to L1 (2nd 1) and List2 to L2 (2nd 2), and leave Freq1 and Freq2 as 1. For μ1 choose the alternative hypothesis: ≠μ2 for a two-tailed test, <μ2 or >μ2 for a one-tailed test. Move to Pooled, highlight Yes and press enter. |
2-SampTTest Inpt:[Data] Stats List1:L1 List2:L2 Freq1:1 Freq2:1 μ1:[≠μ2] <μ2 >μ2 Pooled:No [Yes] Calculate Draw |
Move down to Calculate and press enter. The screen shows the test statistic t, the p-value, the degrees of freedom df, the two sample means, the two standard deviations and, because Pooled is Yes, the pooled standard deviation Sxp. Scroll down with ▼ to see the rest. , and . |
2-SampTTest μ1≠μ2 t=3.3372202 p=0.0045018 df=15 x̄1=73.2500000 x̄2=65.5555556 Sx1=5.2847489 Sx2=4.2163702 Sxp=4.7449779 n1=8 n2=9 |
If the question gives the means, standard deviations and sizes instead of the raw data, set Inpt to Stats and type them in.
The full guide: Two-sample t-test (comparing two means)
Interpret p-values and significance levels
Used in: Chi-squared test, t-test
How to read a p-value on a TI-84 Plus CE (chi-squared goodness-of-fit test)
Run the test, then compare p with the significance level | |
Press stat and choose 1:Edit.... Type the observed counts in L1 and the expected counts in L2, pressing enter after each. |
L1 L2 28 20 18 20 14 20 |
Press stat, press ▶ twice to reach TESTS and choose D:χ²GOF-Test.... With the Stat Wizards on, set Observed to L1 (2nd 1), Expected to L2 (2nd 2) and df to 2, then choose Calculate. |
χ²GOF-Test Observed:L1 Expected:L2 df:2 Calculate |
The screen shows χ², p and df. The value after p= is the p-value. Compare it with the significance level: if p is smaller, reject ; if it is larger, do not. and to 3 significant figures. Since , do not reject . |
χ²GOF-Test χ²=5.2 p=0.0742736 df=2 CNTRB={3.2,0.2,1.8} |
The calculator never says reject or do not reject. It gives only p. You compare p with the significance level yourself and write the conclusion.
The full guide: Interpret p-values and significance levels
See the full list of GDC guides for every calculator task.
Syllabus content covered
| Code | Syllabus content |
|---|---|
| SL4.11 | Formulation of null and alternative hypotheses, and . Significance levels, p-values, expected and observed frequencies. The test for independence: contingency tables, degrees of freedom, critical value. The goodness of fit test. The t-test, using the p-value to compare the means of two populations, one- and two-tailed tests. |
Official IB source: Mathematics: applications and interpretation subject brief (PDF, ibo.org).
Quick questions
How do you find the degrees of freedom for a chi-squared test of independence?
For a contingency table, . For a goodness-of-fit test it is instead the number of categories minus 1.
How do I know if a t-test should be one-tailed or two-tailed?
Use a one-tailed test ( with or ) when the claim states a direction, such as "increases" or "is less than". Use a two-tailed test ( with ) when the claim only says the means are "different".
How do you calculate an expected frequency in a contingency table?
, calculated for each cell under the assumption that the two variables are independent.
What is the decision rule for a t-test?
Reject if the -value is less than the significance level ; otherwise do not reject . The -value itself is read directly from the GDC's -test output.
What are the hypotheses for a test for independence?
states that the two variables are independent, meaning not associated. states that the two variables are not independent, meaning they are associated.
What does 'do not reject ' mean?
It means the data does not give enough evidence against . It does not prove that is true.
Why must the expected frequencies be greater than ?
The test is only valid when every expected frequency is greater than . If a cell is 5 or less, neighbouring categories may need to be combined before the test is used.
Why are hypotheses written with and and not and ?
Hypotheses are statements about the population means and , which are unknown. The sample means and are calculated from the data and are used as evidence about them.
How do I write the conclusion from the -value?
If the -value is less than the significance level, reject and say there is evidence of an association, or that the data does not fit the distribution. Otherwise do not reject , and state this in context.
What assumptions does a -test need?
The populations are assumed to be approximately normally distributed, and the samples should be random and independent of each other. At this level the two groups are assumed to have equal variances, so the pooled test is used.
Ready to practise properly?
Practice questions on every section, marked instantly like the real exam.