*51*

A **two sample t-test** is used to determine whether or not two population means are equal.

This tutorial explains the following:

- The motivation for performing a two sample t-test.
- The formula to perform a two sample t-test.
- The assumptions that should be met to perform a two sample t-test.
- An example of how toÂ perform a two sample t-test.

**Two Sample t-test: Motivation**

Suppose we want to know whether or not the mean weight between two different species of turtles is equal. Since there are thousands of turtles in each population, it would be too time-consuming and costly to go around and weigh each individual turtle.

Instead, we might take a simple random sample of 15 turtles from each population and use the mean weight in each sample to determine if the mean weight is equal between the two populations:

However, itâ€™s virtually guaranteed that the mean weight between the two samples will be at least a little different. **The question is whether or not this difference is statistically significant**. Fortunately, a two sample t-test allows us to answer this question.

**Two Sample t-test:**** Formula**

A two-sample t-test always uses the following null hypothesis:

**H**Î¼_{0}:_{1}Â =Â Î¼_{2}(the two population means are equal)

The alternative hypothesis can be either two-tailed, left-tailed, or right-tailed:

**H**Î¼_{1}(two-tailed):Â â‰ Î¼_{1}_{2}(the two population means are not equal)**H**Î¼_{1}(left-tailed):_{1}Â 2Â (population 1 mean is less than population 2 mean)**H**Î¼_{1}(right-tailed):Â> Î¼_{1}_{2}Â (population 1 mean is greater than population 2 mean)

We use the following formula to calculate the test statistic t:

**Test statistic:**Â (x_{1}Â â€“Â x_{2})Â /Â s_{p}(âˆš1/n_{1}Â + 1/n_{2})

whereÂ x_{1}Â andÂ x_{2} are the sample means,Â n_{1 }and n_{2Â }are the sample sizes, and whereÂ s_{p} is calculated as:

**s _{p}** =Â âˆšÂ (n

_{1}-1)s

_{1}

^{2}Â +Â Â (n

_{2}-1)s

_{2}

^{2}Â /Â (n

_{1}+n

_{2}-2)

where s_{1}^{2}Â and s_{2}^{2}Â are the sample variances.

If the p-value that corresponds to the test statistic t with (n_{1}+n_{2}-1) degrees of freedom is less than your chosen significance level (common choices are 0.10, 0.05, and 0.01) then you can reject the null hypothesis.

**Two Sample t-test: Assumptions**

For the results of a two sample t-test to be valid, the following assumptions should be met:

- The observations in one sample should be independent of the observations in the other sample.
- The data should be approximately normally distributed.
- The two samples should have approximately the same variance. If this assumption is not met, you should instead perform Welchâ€™s t-test.
- The data in both samples was obtained using a random sampling method.

**Two Sample t-test****: Example**

Suppose we want to know whether or not the mean weight between two different species of turtles is equal. To test this, will perform a two sample t-test at significance level Î± = 0.05 using the following steps:

**Step 1: Gather the sample data.**

SupposeÂ we collect a random sample of turtles from each population with the following information:

**Sample 1:**

- Sample sizeÂ n
_{1}= 40 - Sample mean weightÂ x
_{1}Â = 300 - Sample standard deviationÂ s
_{1}= 18.5

**Sample 2:**

- Sample sizeÂ n
_{2}= 38 - Sample mean weightÂ x
_{2}Â = 305 - Sample standard deviationÂ s
_{2}= 16.7

**Step 2: Define the hypotheses.**

We will perform the two sample t-test with the following hypotheses:

**H**Î¼_{0}:Â_{1}Â = Î¼_{2}(the two population means are equal)**H**Î¼_{1}:Â_{1}Â â‰ Î¼_{2}(the two population means are not equal)

**Step 3: Calculate the test statisticÂ t.**

First, we will calculate the pooled standard deviation s_{p}:

**s _{p}** =Â âˆšÂ (n

_{1}-1)s

_{1}

^{2}Â +Â Â (n

_{2}-1)s

_{2}

^{2}Â /Â (n

_{1}+n

_{2}-2)Â =Â âˆšÂ (40-1)18.5

^{2}Â +Â Â (38-1)16.7

^{2}Â /Â (40+38-2)Â =

**17.647**

Next, we will calculate the test statisticÂ *t*:

**t** =Â (x_{1}Â â€“Â x_{2})Â /Â s_{p}(âˆš1/n_{1}Â + 1/n_{2}) =Â (300-305) / 17.647(âˆš1/40Â + 1/38) =Â **-1.2508**

**Step 4: Calculate the p-value of the test statisticÂ t.**

According to the T Score to P Value Calculator, the p-value associated with t = -1.2508 and degrees of freedom = n_{1}+n_{2}-2 = 40+38-2 = 76 isÂ **0.21484**.

**Step 5: Draw a conclusion.**

Since this p-value is not less than ourÂ significance level Î± = 0.05, we fail to reject the null hypothesis. We do not have sufficient evidence to say that the mean weight of turtles between these two populations is different.

**Note:Â **You can also perform this entire two sample t-test by simply using the Two Sample t-test Calculator.

**Additional Resources**

The following tutorials explain how to perform a two-sample t-test using different statistical programs:

How to Perform a Two Sample t-test in Excel

How to Perform a Two Sample t-test in SPSS

How to Perform a Two Sample t-test in Stata

How to Perform a Two Sample t-test in R

How to Perform a Two Sample t-test in Python

How to Perform a Two Sample t-test on a TI-84 Calculator