Two Sample t-Test

This lesson will focus on how to perform a two-sample t-test in Python.

We'll cover the following

Two-sample t-test

A two-sample t-test checks whether means of two independent samples differ from each other. We can use the function ttest_ind from the scipy.stats module to perform the two-sample t-test.

We will be using the Student Alcohol Consumption Dataset. We will divide the data into two groups based on alcohol consumption. Then we will find the mean grade for both groups. We will check if the mean grades for both groups differ from each other or not.

Null hypothesis H0H_0: x1ˉ=x2ˉ\bar{x_1} = \bar{x_2}

Alternate hypothesis HaH_a: x1ˉx2ˉ\bar{x_1} \neq \bar{x_2}

We choose α\alpha to be at 95%95\% confidence level which means α=1(conf.level)=10.95=0.05\alpha =1 - (conf.level) = 1 - 0.95 = 0.05

Get hands-on with 1400+ tech skills courses.