One Sample t-Test

This lesson will focus on how to perform one sample t-tests in Python.

We'll cover the following

One-sample t-test

A One sample t-test checks whether a population mean differs from the sample mean or not. We can use the function ttest_1samp from the scipy.stats module.

We will be using the Student Alcohol Consumption Dataset. We will take a sample from the data and find the mean grade. We will check if the population mean grade (μ\mu) differs from the sample mean grade (xˉ\bar{x}) or not.

Null hypothesis H0H_0: xˉ=μ\bar{x} = \mu

Alternate hypothesis HaH_a: xˉμ\bar{x} \neq \mu

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 1200+ tech skills courses.