The chi-squared test in IB Maths is difficult to set up because several decisions must be correct before the calculator can do anything useful. You must identify the test, translate the null hypothesis into expected frequencies, enter the observed table accurately, and select the correct degrees of freedom. A calculator can evaluate the test, but it cannot repair a table built from the wrong assumptions.
The two most common error points are expected values and degrees of freedom. Both depend on understanding what the null hypothesis says, rather than simply recalling a calculator procedure. This guide concentrates on those setup decisions without duplicating the wider syllabus coverage in IB Maths AI hypothesis testing explained and practised.
Why does the chi-squared test feel harder than its formula?
The calculation itself is compact:
Here, is an observed frequency and is the corresponding expected frequency under the null hypothesis. Each cell contributes a non-negative amount, so a large value indicates substantial disagreement between the observations and what the null hypothesis predicts.
The difficulty lies in constructing . Expected frequencies are not estimates of what will happen in a future sample, and they are not values chosen to look similar to the observations. They are the frequencies the model would produce if were true, while preserving the relevant totals from the sample.
This creates a chain of dependence:
-
The wording determines the hypotheses.
-
The null hypothesis determines the expected frequencies.
-
The table structure determines the degrees of freedom.
-
The degrees of freedom determine the relevant chi-squared distribution.
-
That distribution determines the p-value or critical value.
One incorrect setup choice can therefore alter every later result. The broader IB Maths AI statistics and probability resources place this test within Topic 4, while this article isolates the setup logic that most often causes mistakes.
Which chi-squared test are you setting up?
In IB Maths AI hypothesis testing, students commonly meet two forms of the chi-squared test. They use the same statistic, but their hypotheses, expected frequencies, and degrees of freedom are set up differently.
FeatureTest for independenceGoodness-of-fit testData structureTwo categorical variables in a contingency tableOne categorical variable divided into categoriesMain questionAre the variables associated?Does the observed distribution fit a stated model?Typical null hypothesisThe variables are independentThe data follow the stated distributionExpected frequencyE=\\frac{(\\text{row total})(\\text{column total})}{\\text{grand total}}$$E=n\\times p for each stated probability Usual IB degrees of freedom(r-1)(c-1)$$k-1, where is the number of categories
A question involving two labels for every individual usually suggests an independence test. For example, each student might be classified by year group and preferred transport method. A question comparing one set of category counts with claimed proportions, such as the outcomes of a supposedly fair die, suggests a goodness-of-fit test.
Do not identify the test merely because the question contains a table. A one-way goodness-of-fit question may also be displayed in tabular form. Count the underlying categorical variables, not the physical rows visible on the page.
How should the hypotheses be written?
For a test of independence, the hypotheses must name the variables:
-
: Year group and preferred transport method are independent.
-
: Year group and preferred transport method are not independent.
Writing only “there is no correlation” is unsuitable. Correlation normally describes a numerical relationship, whereas a chi-squared independence test examines an association between categorical variables.
For goodness of fit, refer to the claimed distribution:
-
: The outcomes follow the stated probability distribution.
-
: The outcomes do not follow the stated probability distribution.
The alternative is not usually that every category differs. The test asks whether the overall disagreement is too large to attribute plausibly to sampling variation.
How are expected values calculated correctly?
Expected frequencies in a test for independence
Suppose students are classified by year group and preferred method of travelling to school:
TransportYear 1Year 2Row totalBus321850Walk202040Car181230Column total7050120
These are observed frequencies. Under , transport preference and year group are independent. The expected frequency in each cell is
For the Bus and Year 1 cell,
The complete expected table is:
TransportYear 1 expectedYear 2 expectedRow totalBus29.166720.833350Walk23.333316.666740Car17.512.530Column total7050120
Notice that the expected table has the same row totals, column totals, and grand total as the observed table. This is an essential checking method. If those totals do not match, at least one expected frequency is wrong.
The formula follows directly from independence. The estimated proportion of students who prefer the bus is , while the Year 1 total is 70. If the variables are independent, the expected number of Year 1 bus users is
This is equivalent to row total multiplied by column total, divided by the grand total. Penn State's explanation of expected counts in contingency tables develops the same reasoning from the independence model.
Expected frequencies in goodness of fit
For goodness of fit, the expected values come from the probabilities stated in . If a fair six-sided die is rolled 120 times, each face has probability , so every expected frequency is
If the proposed probabilities are unequal, calculate each expectation separately. For probabilities , , and in a sample of 200, the expected frequencies are 40, 60, and 100.
Why rounding expected values early is dangerous
Expected frequencies do not need to be whole numbers. They are theoretical counts, not recorded observations. Keep the calculator's full precision during the test and round only displayed answers as requested.
Early rounding can make the expected row or column totals inconsistent and can slightly alter and the p-value. In a borderline decision, that avoidable change may affect the conclusion.
How do degrees of freedom work?
For an contingency table, the degrees of freedom are
In the transport example there are three genuine data rows and two genuine data columns, so
Do not count the totals row or totals column. The table may appear to have four rows and three columns on the page, but its statistical dimensions are .
Degrees of freedom describe how many cell values can vary independently once the totals constrain the table. In the expected table, knowing enough cells and all marginal totals forces the remaining entries. This loss of freedom is why the number of cells, six, is not the degrees of freedom.
For a goodness-of-fit test with categories, the standard IB result is
If a fair die has six categories, . One degree of freedom is lost because once five category frequencies and the total are fixed, the sixth is determined. In more advanced statistics, degrees of freedom may be reduced further when distribution parameters are estimated from the same data, but standard IB Maths AI SL goodness-of-fit questions use the syllabus case .
A complete setup and calculation
Using the transport data, the hypotheses are:
-
: Year group and preferred transport method are independent.
-
: Year group and preferred transport method are not independent.
The expected table is calculated from the marginal totals, and . Substituting the observed and expected frequencies gives
For two degrees of freedom, technology gives approximately
At the 5% significance level, , so we fail to reject . There is insufficient evidence to suggest an association between year group and preferred transport method.
This wording matters. The result does not prove that the variables are independent. It says the sample does not provide sufficiently strong evidence against independence at the selected significance level. The RevisionDojo guide to interpreting IB hypothesis tests explains this distinction in greater depth.
What conditions and IB requirements matter?
The current Mathematics: Applications and Interpretation syllabus places chi-squared tests within Topic 4, Statistics and Probability, including hypothesis testing at SL. The published course guide states that examination questions use technology for the statistic and p-value, use upper-tail tests at common significance levels, and provide a critical value where appropriate.
The guide also states that expected frequencies in examination questions will be greater than 5. For investigations beyond controlled examination questions, including an IA, students should recognize that small expected frequencies can make the chi-squared approximation unreliable. The commonly taught conservative check is that expected frequencies should be at least 5, although more advanced statistical sources use slightly different conditions depending on table size.
Also check that:
-
The data are frequencies, not percentages, means, or raw measurements.
-
Categories are mutually exclusive, so each observation enters one cell only.
-
Observations are suitably independent.
-
The expected frequencies arise from .
-
Every observed cell is paired with the corresponding expected cell.
These conditions matter because the chi-squared distribution is an approximation to the sampling behaviour of the statistic. The NIST contingency-table guidance and Penn State's formal account of two-way independence tests provide further statistical justification.
Common setup mistakes and how to prevent them
MistakeWhy it is wrongReliable correctionEntering percentages instead of frequenciesThe statistic compares countsRecover or use the actual category countsTreating expected values as predictionsExpectations must represent Ask, “What counts would occur under the null model?”Using observed values as expected valuesThis forces Calculate a separate expected tableCounting totals in and Totals are constraints, not categoriesCount only genuine category rows and columnsUsing for an independence tableThat formula belongs to standard goodness of fitUse Rounding expected values to integersExpected frequencies may be decimal valuesRetain full calculator precisionConcluding “accept ”A non-significant result does not prove Write “fail to reject ”Entering row totals into the observed matrixTotals are not tested cellsEnter only the interior observed counts
A useful ten-second check is H-E-D:
-
H: Do the hypotheses name the variables or distribution?
-
E: Do the expected values match the null hypothesis and preserve the totals?
-
D: Were degrees of freedom calculated without totals?
How should you use the calculator in an exam?
Your graphic display calculator should evaluate the statistic and p-value, but you should understand what the input represents. Enter only the observed frequencies into the appropriate matrix or table. Do not include marginal totals unless your calculator's specific interface explicitly requests them.
After running the test, inspect the expected matrix if your calculator displays one. Check its dimensions and totals before trusting the p-value. Calculator models use different menus, so practise on the exact approved model you will take into the examination.
The best revision method is to alternate between conceptual setup and calculator execution. Use the chi-squared video lessons to review the process, then complete targeted problems in the IB Maths AI hypothesis-testing Questionbank. Jojo AI can help identify whether an error began in the hypotheses, expected table, degrees of freedom, or final interpretation.
Conclusion
The chi-squared test is hard to set up because its inputs encode the entire null hypothesis. Expected frequencies must describe the data under , while degrees of freedom must reflect the independent information left after totals impose constraints. Once those two ideas are secure, the statistic and p-value become comparatively routine.
For exam preparation, write the hypotheses before touching the calculator, verify that expected and observed tables have matching totals, and count only genuine categories when finding degrees of freedom. RevisionDojo's focused videos, Study Notes, Jojo AI feedback, and Questionbank practice can help turn those checks into a consistent exam routine.
