0% found this document useful (0 votes)
5 views22 pages

Testing

The document provides an overview of hypothesis testing, specifically focusing on the Chi-squared distribution, including tests for independence and goodness of fit. It explains key concepts such as null and alternative hypotheses, significance levels, and the steps to conduct Chi-squared tests. Additionally, it includes practical examples and tips for writing conclusions based on test results.

Uploaded by

pooja.jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views22 pages

Testing

The document provides an overview of hypothesis testing, specifically focusing on the Chi-squared distribution, including tests for independence and goodness of fit. It explains key concepts such as null and alternative hypotheses, significance levels, and the steps to conduct Chi-squared tests. Additionally, it includes practical examples and tips for writing conclusions based on test results.

Uploaded by

pooja.jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

DP IB Applications & Your notes

Interpretation (AI): HL
Hypothesis Testing using the Chi-squared
Distribution
Contents
Hypothesis Testing
Chi-squared Test for Independence
Goodness of Fit Test

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 1
Hypothesis Testing
Your notes
Language of Hypothesis Testing
What is a hypothesis test?
A hypothesis test uses a sample of data in an experiment to test a statement made
about the population
The statement is either about a population parameter or the distribution of the
population
The hypothesis test will look at the probability of observed outcomes happening under
set conditions
The probability found will be compared against a given significance level to determine
whether there is evidence to support the statement being made

What are the key terms used in statistical hypothesis testing?


Every hypothesis test must begin with a clear null hypothesis (what we believe to
already be true) and alternative hypothesis (how we believe the data pattern or
probability distribution might have changed)
A hypothesis is an assumption that is made about a particular population parameter or
the distribution of the population
A population parameter is a numerical characteristic which helps define a
population
Such as the mean value of the population

The null hypothesis is denoted H and sets out the assumed population parameter
0
or distribution given that no change has happened

The alternative hypothesis is denoted H and sets out how we think the population
1
parameter or distribution could have changed
When a hypothesis test is carried out, the null hypothesis is assumed to be true and
this assumption will either be accepted or rejected
When a null hypothesis is accepted or rejected a statistical inference is made
A hypothesis test will always be carried out at an appropriate significance level
The significance level sets the smallest probability that an event could have
occurred by chance
Any probability smaller than the significance level would suggest that the event
is unlikely to have happened by chance
The significance level must be set before the hypothesis test is carried out
The significance level will usually be 1%, 5% or 10%, however it may vary

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 2
One-tailed Tests
What are one-tailed tests? Your notes

A one-tailed test is used for testing:


Whether a distribution can be used to model the population
Whether the population parameter has increased
Whether the population parameter has decreased
One-tailed tests can be used with:
Chi-squared test for independence
Chi-squared goodness of fit test
Test for proportion of a binomial distribution
Test for population mean of a Poisson distribution
Test for population mean of a normal distribution
Test to compare population means of two distributions

Two-tailed Tests
What are two-tailed tests?
A two-tailed test is used for testing:
Whether the population parameter has changed
Two-tailed tests can be used with:
Test for population mean of a normal distribution
Test to compare population means of two distributions

Conclusions of Hypothesis Testing


How do I decide whether to reject or accept the null
hypothesis?
A sample of the population is taken and the test statistic is calculated using the
observations from the sample
Your GDC can calculate the test statistic for you (if required)
To decide whether or not to reject the null hypothesis you first need either the p-value or
the critical region
The p - value is the probability of a value being at least as extreme as the test statistic,
assuming that the null hypothesis is true
Your GDC will give you the p-value (if required)

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 3
If the p-value is less than the significance level then the null hypothesis would be
rejected
The critical region is the range of values of the test statistic which will lead to the null Your notes
hypothesis being rejected
If the test statistic falls within the critical region then the null hypothesis would be
rejected
The critical value is the boundary of the critical region
It is the least extreme value that would lead to the rejection of the null hypothesis
The critical value is determined by the significance level
How should a conclusion be written for a hypothesis test?
Your conclusion must be written in the context of the question
Use the wording in the question to help you write your conclusion
If rejecting the null hypothesis your conclusion should state that there is sufficient
evidence to suggest that the null hypothesis is unlikely to be true
If accepting the null hypothesis your conclusion should state that there is not
enough evidence to suggest that the null hypothesis is unlikely to be true
Your conclusion must not be definitive
There is a chance that the test has led to an incorrect conclusion
The outcome is dependent on the sample
a different sample might lead to a different outcome
The conclusion of a two-tailed test can state if there is evidence of a change
You should not state whether this change is an increase or decrease
If you are testing the difference between the means of two populations then you
can only conclude that the means are not equal
You can not say which population mean is bigger
You’d need to use a one-tailed test for this

Examiner Tips and Tricks


Accepting the null hypothesis does not mean that you are saying it is true
You are simply saying there is not enough evidence to reject it

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 4
Chi-squared Test for Independence
Your notes
Chi-Squared Test for Independence
What is a chi-squared test for independence?
A chi-squared ( χ 2 ) test for independence is a hypothesis test used to test whether two
variables are independent of each other

This is sometimes called a χ 2 two-way test

This is an example of a goodness of fit test


We are testing whether the data fits the model that the variables are independent

The chi-squared (χ 2 ) distribution is used for this test

You will use a contingency table


This is a two-way table that shows the observed frequencies for the different
combinations of the two variables
For example: if the two variables are hair colour and eye colour then the
contingency table will show the frequencies of the different combinations

Why might I have to combine rows or columns?


The observed values are used to calculate expected values
These are the expected frequencies for each combination assuming that the
variables are independent
Your GDC can calculate these for you after you input the observed frequencies
The expected values must all be bigger than 5
If one of the expected values is less than 5 then you will have to combine the
corresponding row or column in the matrix of observed values with the adjacent row or
column
The decision between row or column will be based on which seems the most
appropriate
For example: if the two variables are age and favourite TV genre then it is more
appropriate to combine age groups than types of genre

What are the degrees of freedom?


There will be a minimum number of expected values you would need to know in order to
be able to calculate all the expected values

This minimum number is called the degrees of freedom and is often denoted by ν

For a test for independence with an m × n contingency table

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 5
ν= m−1
( ) × n −1
( )

For example: If there are 5 rows and 3 columns then you only need to know 2 of the Your notes
values in 4 of the rows as the rest can be calculated using the totals
What are the steps for a chi-squared test for independence?
STEP 1: Write the hypotheses
H0 : Variable X is independent of variable Y
H1 : Variable X is not independent of variable Y
Make sure you clearly write what the variables are and don’t just call them X and
Y
STEP 2: Calculate the degrees of freedom for the test
For an m × n contingency table

Degrees of freedom is ν = m−1 × n −1


( ) ( )

STEP 3: Enter your observed frequencies into your GDC using the option for a 2-way
test
Enter these as a matrix
Your GDC will give you a matrix of the expected values (assuming the variables are
independent)
If any values are 5 or less then combine rows/columns and repeat step 2
Your GDC will also give you the χ² statistic and its p-value

The χ² statistic is denoted as χ 2


calc

STEP 4: Decide whether there is evidence to reject the null hypothesis


EITHER compare the χ² statistic with the given critical value
If χ² statistic > critical value then reject H0
If χ² statistic < critical value then accept H0
OR compare the p-value with the given significance level
If p-value < significance level then reject H0
If p-value > significance level then accept H0
STEP 5: Write your conclusion
If you reject H0
There is sufficient evidence to suggest that variable X is not independent of
variable Y
Therefore this suggests they are associated
If you accept H0

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 6
There is insufficient evidence to suggest that variable X is not independent of
variable Y
Your notes
Therefore this suggests they are independent
How do I calculate the chi-squared statistic?
You are expected to be able to use your GDC to calculate the χ² statistic by inputting the
matrix of the observed frequencies
Seeing how it is done by hand might deepen your understanding but you are not
expected to use this method
STEP 1: For each observed frequency Oi calculate its expected frequency Ei
Assuming the variables are independent
Ei = P(X = x) × P(Y = y) × Total
Row Total× Column Total
Which simplifies to E
i
= Overall Total

STEP 2: Calculate the χ² statistic using the formula

Oi −Ei 2
χ 2calc = ∑
( )

Ei

You do not need to learn this formula as your GDC calculates it for you
To calculate the p-value you would find the probability of a value being bigger than your
χ² statistic using a χ² distribution with ν degrees of freedom

Examiner Tips and Tricks


Note for Internal Assessments (IA)
If you use a χ² test in your IA then beware that the outcome may not be accurate if
there is only 1 degree of freedom
This means it is a 2 × 2 contingency table

Worked Example
At a school in Paris, it is believed that favourite film genre is related to favourite
subject. 500 students were asked to indicate their favourite film genre and favourite
subject from a selection and the results are indicated in the table below.

Comedy Action Romance Thriller

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 7
Maths 51 52 37 55

Sports 59 63 41 33 Your notes

Geography 35 31 28 15

It is decided to test this hypothesis by using a χ 2 test for independence at the 1%


significance level.
The critical value is 16.812.
a) State the null and alternative hypotheses for this test.

b) Write down the number of degrees of freedom for this table.

c) Calculate the χ 2 test statistic for this data.

d) Write down the conclusion to the test. Give a reason for your answer.

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 8
Your notes

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 9
Goodness of Fit Test
Your notes
Chi-Squared GOF: Uniform
What is a chi-squared goodness of fit test for a given
distribution?
A chi-squared ( χ 2 ) goodness of fit test is used to test data from a sample which
suggests that the population has a given distribution
This could be that:
the proportions of the population for different categories follows a given ratio
the population follows a uniform distribution
This means all outcomes are equally likely

What are the steps for a chi-squared goodness of fit test for a
given distribution?
STEP 1: Write the hypotheses
H0 : Variable X can be modelled by the given distribution
H1 : Variable X cannot be modelled by the given distribution
Make sure you clearly write what the variable is and don’t just call it X
STEP 2: Calculate the expected frequencies
Split the total frequency using the given ratio
For a uniform distribution: divide the total frequency N by the number of possible
outcomes k
STEP 3: Calculate the degrees of freedom for the test
For k possible outcomes

Degrees of freedom is ν =k −1
STEP 4: Enter the frequencies and the degrees of freedom into your GDC
Enter the observed and expected frequencies as two separate lists
Your GDC will then give you the χ² statistic and its p-value

The χ² statistic is denoted as χ 2


calc

STEP 5: Decide whether there is evidence to reject the null hypothesis


EITHER compare the χ² statistic with the given critical value
If χ² statistic > critical value then reject H0

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 10
If χ² statistic < critical value then accept H0
OR compare the p-value with the given significance level
Your notes
If p-value < significance level then reject H0
If p-value > significance level then accept H0
STEP 6: Write your conclusion
If you reject H0
There is sufficient evidence to suggest that variable X does not follow the given
distribution
Therefore this suggests that the data is not distributed as claimed
If you accept H0
There is insufficient evidence to suggest that variable X does not follow the
given distribution
Therefore this suggests that the data is distributed as claimed

Worked Example
A car salesman is interested in how his sales are distributed and records his sales
results over a period of six weeks. The data is shown in the table.

Week 1 2 3 4 5 6

Number of sales 15 17 11 21 14 12

A χ 2 goodness of fit test is to be performed on the data at the 5% significance level


to find out whether the data fits a uniform distribution.
a) Find the expected frequency of sales for each week if the data were uniformly
distributed.

b) Write down the null and alternative hypotheses.

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 11
Your notes

c) Write down the number of degrees of freedom for this test.

d) Calculate the p-value.

e) State the conclusion of the test. Give a reason for your answer.

Chi-Squared GOF: Binomial


What is a chi-squared goodness of fit test for a binomial
distribution?

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 12
A chi-squared ( χ 2 ) goodness of fit test is used to test data from a sample suggesting
that the population has a binomial distribution
Your notes
You will either be given a precise binomial distribution to test B ( n , p with an
)

assumed value for p


Or you will be asked to test whether a binomial distribution is suitable without being
given an assumed value for p
In this case you will have to calculate an estimate for the value of p for the
binomial distribution
To calculate it divide the mean by the value of n

=n×∑
x⎯⎯ 1 fx
p=
n ∑f
What are the steps for a chi-squared goodness of fit test for a
binomial distribution?
STEP 1: Write the hypotheses
H0 : Variable X can be modelled by a binomial distribution
H1 : Variable X cannot be modelled by a binomial distribution
Make sure you clearly write what the variable is and don’t just call it X
If you are given the assumed value of p then state the precise distribution
B n, p
( )

STEP 2: Calculate the expected frequencies


If you were not given the assumed value of p then you will first have to estimate it
using the observed data

Find the probability of the outcome using the binomial distribution P ( X =x )

Multiply the probability by the total frequency P ( X =x ) ×N


You will have to combine rows/columns if any expected values are 5 or less
STEP 3: Calculate the degrees of freedom for the test
For k outcomes (after combining expected values if needed)
Degrees of freedom is

ν = k − 1 if you were given the assumed value of p


ν = k − 2 if you had to estimate the value of p
STEP 4: Enter the frequencies and the degrees of freedom into your GDC
Enter the observed and expected frequencies as two separate lists

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 13
Your GDC will then give you the χ² statistic and its p-value

The χ² statistic is denoted as χ 2 Your notes


calc
STEP 5: Decide whether there is evidence to reject the null hypothesis
EITHER compare the χ² statistic with the given critical value
If χ² statistic > critical value then reject H0
If χ² statistic < critical value then accept H0
OR compare the p-value with the given significance level
If p-value < significance level then reject H0
If p-value > significance level then accept H0
STEP 6: Write your conclusion
If you reject H0
There is sufficient evidence to suggest that variable X does not follow the
binomial distribution B n p
( , )

Therefore this suggests that the data does not follow B ( n, p )

If you accept H0
There is insufficient evidence to suggest that variable X does not follow the
binomial distribution B n p
( , )

Therefore this suggests that the data follows B ( n, p )

Worked Example
A stage in a video game has three boss battles. 1000 people try this stage of the
video game and the number of bosses defeated by each player is recorded.

Number of bosses defeated 0 1 2 3

Frequency 490 384 111 15

A χ 2 goodness of fit test at the 5% significance level is used to decide whether the
number of bosses defeated can be modelled by a binomial distribution with a 20%
probability of success.
a) State the null and alternative hypotheses.

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 14
Your notes

b) Assuming the binomial distribution holds, find the expected number of people that
would defeat exactly one boss.

c) Calculate the p-value for the test.

d) State the conclusion of the test. Give a reason for your answer.

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 15
Your notes

Chi-Squared GOF: Normal


What is a chi-squared goodness of fit test for a normal
distribution?
A chi-squared ( χ 2 ) goodness of fit test is used to test data from a sample suggesting
that the population has a normal distribution

You will either be given a precise normal distribution to test N ( μ , σ 2 with


)

assumed values for μ and σ


Or you will be asked to test whether a normal distribution is suitable without being
given assumed values for μ and/or σ
In this case you will have to calculate an estimate for the value of μ and/or σ for
the normal distribution
Either use your GDC or use the formulae

x⎯⎯ =
∑fx n
= n − 1 s 2n
∑f and s 2
n −1

What are the steps for a chi-squared goodness of fit test for a
normal distribution?
· STEP 1: Write the hypotheses
H0 : Variable X can be modelled by a normal distribution
H1 : Variable X cannot be modelled by a normal distribution
Make sure you clearly write what the variable is and don’t just call it X
If you are given the assumed values of μ and σ then state the precise distribution
N μ, σ2
( )

STEP 2: Calculate the expected frequencies


If you were not given the assumed values of μ or σ then you will first have to estimate
them

Find the probability of the outcome using the normal distribution P ( a <X <b )

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 16
( <
Beware of unbounded inequalities P X b or P X a for the class
) ( > )

intervals on the 'ends'


Your notes
Multiply the probability by the total frequency P a X b
( < < ×
N )

You will have to combine rows/columns if any expected values are 5 or less
STEP 3: Calculate the degrees of freedom for the test
For k class intervals (after combining expected values if needed)
Degrees of freedom is

ν = k − 1 if you were given the assumed values for both μ and σ


ν = k − 2 if you had to estimate either μ or σ but not both
ν = k − 3 if you had to estimate both μ and σ
STEP 4: Enter the frequencies and the degrees of freedom into your GDC
Enter the observed and expected frequencies as two separate lists
Your GDC will then give you the χ² statistic and its p-value

The χ² statistic is denoted as χ 2


calc

STEP 5: Decide whether there is evidence to reject the null hypothesis


EITHER compare the χ² statistic with the given critical value
If χ² statistic > critical value then reject H0
If χ² statistic < critical value then accept H0
OR compare the p-value with the given significance level
If p-value < significance level then reject H0
If p-value > significance level then accept H0
STEP 6: Write your conclusion
If you reject H0
There is sufficient evidence to suggest that variable X does not follow the
normal distribution N μ σ 2
( , )

Therefore this suggests that the data does not follow N ( μ, σ2 )

If you accept H0
There is insufficient evidence to suggest that variable X does not follow the
normal distribution N μ σ 2
( , )

Therefore this suggests that the data follows N ( μ, σ2 )

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 17
Worked Example
300 marbled ducks in Quacktown are weighed and the results are shown in the table Your notes
below.

Mass (g) Frequency

m < 450 1

450 ≤ m < 470 9

470 ≤ m < 520 158

520 ≤ m < 570 123

m ≥ 570 9

A χ 2 goodness of fit test at the 10% significance level is used to decide whether the
mass of a marbled duck can be modelled by a normal distribution with mean 520 g
and standard deviation 30 g.

a) Explain why it is necessary to combine the groups m < 450 and 450 ≤ m < 470
<
to create the group m 470 with frequency 10.

b) Calculate the expected frequencies, giving your answers correct to 2 decimal


places.

c) Write down the null and alternative hypotheses.

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 18
Your notes

d) Calculate the χ 2 statistic.

e) Given that the critical value is 6.251, state the conclusion of the test. Give a reason
for your answer.

Chi-squared GOF: Poisson


What is a chi-squared goodness of fit test for a Poisson
distribution?
A chi-squared (χ²) goodness of fit test is used to test data from a sample suggesting
that the population has a Poisson distribution

You will either be given a precise Poisson distribution to test Po ( m with an


)

assumed value for m


Or you will be asked to test whether a Poisson distribution is suitable without being
given an assumed value for m
In this case you will have to calculate an estimate for the value of m for the
Poisson distribution
To calculate it just calculate the mean

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 19
m=
∑fx
∑f Your notes
What are the steps for a chi-squared goodness of fit test for a
Poisson distribution?
STEP 1: Write the hypotheses
H0 : Variable X can be modelled by a Poisson distribution
H1 : Variable X cannot be modelled by a Poisson distribution
Make sure you clearly write what the variable is and don’t just call it X
If you are given the assumed value of m then state the precise distribution
Po m( )

STEP 2: Calculate the expected frequencies


If you were not given the assumed value of m then you will first have to estimate it
using the observed data

Find the probability of the outcome using the Poisson distribution P ( X =x )

Multiply the probability by the total frequency P ( X =x


×N )

If a is the smallest observed value then calculate P X ≤ a ( )

If b is the largest observed value then calculate P X ≥ b


( )

You will have to combine rows/columns if any expected values are 5 or less
STEP 3: Calculate the degrees of freedom for the test
For k outcomes (after combining expected values if needed)
Degree of freedom is

ν = k − 1 if you were given the assumed value of m


ν = k − 2 if you had to estimate the value of m
STEP 4: Enter the frequencies and the degree of freedom into your GDC
Enter the observed and expected frequencies as two separate lists
Your GDC will then give you the χ² statistic and its p-value

The χ² statistic is denoted as χ 2


calc

STEP 5: Decide whether there is evidence to reject the null hypothesis


EITHER compare the χ² statistic with the given critical value
If χ² statistic > critical value then reject H0
If χ² statistic < critical value then accept H0

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 20
OR compare the p-value with the given significance level
If p-value < significance level then reject H0 Your notes
If p-value > significance level then accept H0
STEP 6: Write your conclusion
If you reject H0
There is sufficient evidence to suggest that variable X does not follow the
Poisson distribution Po m ( )

Therefore this suggests that the data does not follow Po ( m )

If you accept H0
There is insufficient evidence to suggest that variable X does not follow the
Poisson distribution Po m ( )

Therefore this suggests that the data follows Po ( m )

Worked Example
A parent claims the number of messages they receive from their teenage child within
an hour can be modelled by a Poisson distribution. The parent collects data from 100
one hour periods and records the observed frequencies of the messages received
from the child. The parent calculates the mean number of messages received from
the sample and uses this to calculate the expected frequencies if a Poisson model is
used.

Number of messages Observed frequency Expected frequency

0 9 7.28

1 16 a
2 23 24.99

3 22 21.82

4 16 14.29

5 14 7.49

6 or more 0 b

A χ² goodness of fit test at the 10% significance level is used to test the parent’s
claim.
a) Write down null and alternative hypotheses to test the parent’s claim.

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 21
Your notes

b) Show that the mean number of messages received per hour for the sample is 2.62.

c) Calculate the values of a and b , giving your answers to 2 decimal places.

d) Perform the hypothesis test.

© 2025 Save My Exams, Ltd. Get more and ace your exams at savemyexams.com 22

You might also like