IB Maths Help logoIB Maths Help

Two-sample t-test (comparing two means)

Compare the means of two independent samples from raw data with the exact key presses for the TI-84 Plus CE, Casio fx-CG50, Casio fx-CG100 and TI-Nspire CX, plus the Pooled setting and what to write in the exam.

Used inAI SLAI HL

To compare two means, enter the two samples in two lists, open the 2-sample t-test, choose the alternative hypothesis, and set Pooled to Yes (On on a Casio). The calculator gives the test statistic t, the p-value and the degrees of freedom. IB examinations assume the two populations have equal variance, so the pooled test is the one to use. Compare the p-value with the significance level.

Example

Two classes sit the same test. The marks of the 8 students in class A are 72, 65, 78, 81, 69, 74, 77, 70. The marks of the 9 students in class B are 64, 70, 61, 68, 59, 66, 72, 63, 67. Test, at the 5% significance level, whether the mean marks of the two classes are different. Assume the marks are normally distributed with equal variances.

Use H0:μA=μBH_0: \mu_A = \mu_B and H1:μA≠μBH_1: \mu_A \neq \mu_B. The pooled two-sample t-test gives t=3.34t = 3.34, p=0.00450p = 0.00450 and df=15df = 15. Since 0.00450<0.050.00450 < 0.05, reject H0H_0: there is sufficient evidence that the mean marks of the two classes are different.

Choose your calculator

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.

t=3.34t = 3.34, p=0.00450p = 0.00450 and df=15df = 15.

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 sample means, standard deviations and sizes instead of the raw data, set Inpt to Stats and type them in. Make sure the standard deviations are the sample values (Sx), not the population values.

How to do a two-sample t-test on a Casio fx-CG50

Data in two lists, then 2-SAMPLE t Test with Pooled On

Press MENU and choose Statistics. Type the values of the first sample in List 1 and the second sample in List 2, pressing EXE after each. The two lists do not need the same number of values.

List1  List2
 72       64
 65       70
 78       61
 81       68
 69       59
 74       66
 77       72
 70       63
          67

Press F3 (TEST), then F2 (t), then F2 (2-SAMPLE).

Set Data to List. For μ1 choose the alternative hypothesis: ≠μ2 for a two-tailed test, <μ2 or >μ2 for a one-tailed test. Set List(1) to List 1, List(2) to List 2, Freq(1) and Freq(2) to 1, and Pooled to On.

2-Sample t Test
Data:List
μ1:≠μ2
List(1):List1
List(2):List2
Freq(1):1
Freq(2):1
Pooled:On
Execute

Move down to Execute and press F1 (CALC). The screen shows t, the p-value and df, then the sample means, the standard deviations and, because Pooled is On, the pooled standard deviation sp. Scroll down with ▼ to see the rest.

t=3.34t = 3.34, p=0.00450p = 0.00450 and df=15df = 15.

μ1≠μ2
t  =3.3372202
p  =0.0045018
df =15
x̄1=73.2500000
x̄2=65.5555556
sx1=5.2847489
sx2=4.2163702
sp =4.7449779
n1 =8
n2 =9

If the question gives the sample means, standard deviations and sizes instead of the raw data, set Data to Variable and type them in.

How to do a two-sample t-test on a Casio fx-CG100

Data in two lists, then Hypothesis Test with Pooled On

Press HOME and choose Statistics. On the List Editor tab, type the values of the first sample in List 1 and the second sample in List 2, pressing EXE after each. The two lists do not need the same number of values.

List1  List2
 72       64
 65       70
 78       61
 81       68
 69       59
 74       66
 77       72
 70       63
          67

Press ▶ to open the Setup tab. Highlight the first line, press OK and choose Hypothesis Test. Highlight the second line, press OK and choose t Test → 2-Sample t Test.

Setup
Hypothesis Test
2-Sample t Test

Highlight Data, press OK and choose List. Highlight μ1, press OK and choose the alternative hypothesis: ≠μ2 for a two-tailed test, <μ2 or >μ2 for a one-tailed test. Set List(1) to List 1 and List(2) to List 2, and set Pooled to On.

2-Sample t Test
Data:List
μ1:≠μ2
List(1):List1
List(2):List2
Pooled:On

Press ▶, or highlight Execute and press OK. The Results tab shows t, the p-value and df, the sample means, the standard deviations and the pooled standard deviation sp.

t=3.34t = 3.34, p=0.00450p = 0.00450 and df=15df = 15.

μ1≠μ2
t  =3.3372202
p  =0.0045018
df =15
x̄1=73.2500000
x̄2=65.5555556
sx1=5.2847489
sx2=4.2163702
sp =4.7449779

If the question gives the sample means, standard deviations and sizes instead of the raw data, choose Variable instead of List under Data and type them in.

How to do a two-sample t-test on a TI-Nspire CX

Data in two columns, then 2-Sample t Test with Pooled set to Yes

Press home and choose Lists & Spreadsheet. Type the values of the first sample down column A and the values of the second sample down column B, pressing enter after each. The two columns do not need the same number of values.

    A      B
 72       64
 65       70
 78       61
 81       68
 69       59
 74       66
 77       72
 70       63
          67

Press menu → Statistics → Stat Tests → 2-Sample t Test. Set the data input method to Data and choose OK.

Set X1 List to a[] and X2 List to b[], leave the frequency lists as 1, and choose the alternative hypothesis: μ1 ≠ μ2 for a two-tailed test, μ1 < μ2 or μ1 > μ2 for a one-tailed test. Open the Pooled drop-down list and choose Yes. Move between the fields with tab, then press enter on OK.

2-Sample t Test
X1 List:a[]
X2 List:b[]
Freq1 List:1
Freq2 List:1
Alternate Hyp:μ1 ≠ μ2
Pooled:Yes

The results appear in two new columns: t, the p-value PVal, the degrees of freedom df, the two sample means, the two standard deviations and the pooled standard deviation sp.

t=3.34t = 3.34, p=0.00450p = 0.00450 and df=15df = 15.

Title    Two-Sample t Test
Alternate Hyp  μ1 ≠ μ2
t     3.3372202
PVal  0.0045018
df    15
x̄1    73.2500000
x̄2    65.5555556
sx1   5.2847489
sx2   4.2163702
sp    4.7449779

If the question gives the sample means, standard deviations and sizes instead of the raw data, set the data input method to Stats and type them in.

Sources. Key presses follow the manufacturers' documentation: the TI-84 Plus CE eGuide, the TI-Nspire eGuide, the Casio fx-CG50 Software User's Guide (version 3.30) and the Casio fx-CG100 online manual.

What to write in the exam

  • State the hypotheses. Write H0:μ1=μ2H_0: \mu_1 = \mu_2 and H1:μ1≠μ2H_1: \mu_1 \neq \mu_2 (or << or >> for a one-tailed test), in the words of the question, and the significance level.
  • Say which test you used. Write that you used a pooled two-sample t-test on your calculator, and that this assumes both populations are normal with equal variance. Do not write the key presses.
  • Write the p-value. Give it to 3 significant figures, and the value of tt if the question asks for it.
  • Compare and conclude. Compare the p-value with the significance level, say whether H0H_0 is rejected, and finish with a conclusion in the context of the question. Do not say that H0H_0 is proved.
  • Use the calculator papers. The test is done with technology, so it is for a calculator paper. In AI SL the samples are unpaired and the population variances are unknown.

Pooled or not pooled

The setting Pooled decides how the calculator estimates the variance. Yes (or On) combines the two samples into one pooled estimate and assumes the two populations have the same variance, which gives df=n1+n2−2df = n_1 + n_2 - 2. No (or Off) allows different variances and gives a different, non-whole number of degrees of freedom. IB examinations tell you to assume equal variance, so set Pooled to Yes or On.

On the example data, switching Pooled off changes tt to 3.293.29, dfdf to 13.4113.41 and pp to 0.005640.00564. The conclusion is the same here, but the numbers are not, so a wrong setting can lose the accuracy mark.

One-tailed tests

For a one-tailed test, choose the alternative that matches H1H_1 on the calculator. If the question says that group 1 has the higher mean, use μ1>μ2\mu_1 > \mu_2, and enter the group the question calls 1 as the first list. The calculator then gives the one-tailed p-value directly.

Error messages and what to do

CalculatorMessageUsual causeWhat to try
TI-84 Plus CEERR:STATA list holds fewer than two values, so no standard deviation can be found, or the lists are not suitable for a statistics calculation.Check that List1 and List2 name the lists that hold your data, with at least two values in each.
TI-84 Plus CEERR:DIMENSION MISMATCHA frequency list has a different number of values from its data list.Leave Freq1 and Freq2 as 1 unless the data come with frequencies.
Casio fx-CG50Dimension ERRORA frequency list has a different number of values from its data list.Set Freq(1) and Freq(2) to 1 unless the data come with frequencies.
Casio fx-CG100Dimension ERRORA frequency list has a different number of values from its data list.Leave the frequencies at 1 unless the data come with frequencies.
TI-Nspire CXDimension mismatchA frequency list has a different number of values from its data list.Leave the frequency lists as 1 unless the data come with frequencies.

Common mistakes

  • Leaving Pooled on No. The exam assumes equal variances, so Pooled must be Yes (TI) or On (Casio). Check it before you calculate.
  • Choosing the wrong alternative. The calculator uses the alternative you select for the p-value. Pick the one that matches H1H_1, and note that two-tailed is ≠\neq.
  • Swapping the lists in a one-tailed test. The first list is sample 1 in μ1\mu_1. Putting the groups in the other order turns << into >>.
  • Using the paired test. The two-sample test is for two independent groups. Data on the same people before and after are paired and need a different method.
  • Stating that H0H_0 is accepted or proved. Say H0H_0 is rejected or not rejected, and give the conclusion in context.

Practise with your calculator

Choose your course to see the practice sets that use this skill. You can also try practice mode or browse every GDC guide.

Quick questions

How do I do a two-sample t-test on a calculator?

Enter the two samples in two lists, then open the 2-sample t-test: STAT, TESTS, 2-SampTTest on the TI-84 Plus CE; TEST, t, 2-SAMPLE in the Statistics mode on the Casio fx-CG50; Hypothesis Test, t Test, 2-Sample t Test on the Casio fx-CG100; and the Stat Tests, 2-Sample t Test item on the TI-Nspire. Choose the alternative hypothesis, set Pooled, and calculate.

Should I pool the variances?

Yes. The AI syllabus says that in examinations students should assume the variances of the two groups are equal, so the pooled two-sample t-test is used. Set Pooled to Yes (TI) or On (Casio).

Do the two lists need the same number of values?

No. The two samples can have different sizes. The lists only need the same length as their own frequency lists, which are 1 for raw data.

What do I write in the exam?

Write the hypotheses, the significance level, the p-value, the comparison with the significance level and a conclusion in context. Say you used a pooled two-sample t-test on your calculator. Examiners look for the method, not the key presses.