# What is a T-test in statistics?

A t-test is a statistical test that is used to compare the sample mean with the population mean or the means of two groups. A t-test can only be performed when the ** population variance is not known** and the

**or less than 30.**

*sample size is small***Types of t-tests**:

1. One sample t-test

2. Two-sample t-test

**One-sample t-test**

We perform a One-Sample t-test when we want to compare a sample mean with the population mean. The difference from the Z Test is that we do not have the information on Population Variance here. We use the sample standard deviation instead of the population standard deviation in this case. The formula used to perform this test is as follows

**Solved example to understand one-sample t-test**:

Q) A company manufactures batteries with an average lifespan of 2 or more years. An engineer believes this value to be less. Using 10 samples, he measures the average life span to 1.8 years with a standard deviation of 0.15. State the null hypothesis and at a 99% confidence level, is there enough evidence to discard H0?

The null and alternate hypotheses can be defined as

H0 = Average battery lifespan is 2 years.

H1 = Average battery lifespan is less than 2 years.

2. **Two-sample t-test**

We perform a Two-Sample t-test when we want to compare the mean of two samples. The formula used to perform this test is as follows

**Solved example to understand two-sample t-test**:

Here, let’s say we want to determine if on average, boys score 15 marks more than girls in the exam. We do not have the information related to variance (or standard deviation) for girls’ scores or boys’ scores. To perform a t-test, we randomly collect the data of 10 girls and boys with their marks. We choose our ⍺ value (significance level) to be 0.05 as the criteria for Hypothesis Testing.

H0: On average, the marks scored by boys and girls are the same.

H1: On average, boys scored more marks than girls.

**Finding the critical value with the help of the t distribution table**:

DF for a one-sample t-test = n-1

DF for a two-sample t-test = n1+n2–2

You can check the critical value with the help of the t table from the below link