t-test : Definition and Example

t-test : Definition and Example

4 mins read7.9K Views Comment
Vikram Singh
Assistant Manager - Content
Updated on Feb 22, 2023 09:40 IST

In this article, we will discuss t-test, types of t-test (one-sample, independent sample, and paired sample) with the help of examples.



t-test is a statistical significant test for hypothesis testing

There are 3 steps in Hypothesis Testing:

  1. State Null and Alternate Hypothesis
  2. Perform Statistical Test
  3. Accept and reject the Null Hypothesis

In this article, we will discuss the t-test.

Table of Content

What is t-test ?

Statistical method for the comparison of the mean of the two groups of the normally distributed sample(s).

It is used when:

  • Population parameter (mean and standard deviation) is not known
  • Sample size (number of observations) < 30

To know more about normal distribution, read the article Probability Distribution

To know more about mean and variance, To know more about mean and variance, read the article on measures of central tendency and measures of dispersion.

Type of t-test

The T-test is mainly classified into 3 parts:

One Sample

In one sample t-test, we compare the sample mean with the population mean.

Mathematical Formula:

  • Region of rejection lies either on extreme left or extreme right of the distribution.
  • In z-test, we use population standard deviation instead of sample standard deviation.

Let’s understand this by an example:

Problem Statement:

Marks of student are 10.5, 9, 7, 12, 8.5, 7.5, 6.5, 8, 11 and 9.5.

Mean population score is 12 and standard deviation is 1.80.

Is the mean value for student significantly differ from the mean population value.


Firstly, we will calculate the mean of 10 students:


Independent (two-sample t-test):

In this test, we compare the means of two different samples.

Mathematical Formula:


Degree of Freedom:

Degree of freedom is defined as the the number of independent variables.

It is given by:


Note: There are two regions of rejection, one in either directions towards tail of each distribution.

Let’s understand two-sample t-test by an example:

Problem Statement:

The marks of boys and girls are given:

Boys: 12, 14, 10, 8, 16, 5, 3, 9, and 11

Girls: 21, 18, 14, 20, 11, 19, 8, 12, 13, and 15

Is there any significant differnece between marks of males and females i.e. population means are different.



Firstly, we will calculate mean, standard deviation and degree of freedom for marks of boys and girls:

Paired t-test:

In this test, we compare the means of two related or same group at two different time.

Mathematical Formula:


Note: Degree of freedom is n-1.

Let’s understand two-sample t-test by an example:

Problem Statement:

Blood pressure of 8 patients are before and after are recorded:

Before: 180, 200, 230, 240, 170, 190, 200, and 165

After: 140, 145, 150, 155, 120, 130, 140, and 130

Is there any significant difference between BP reading before and after.




t-test is a statistically significant test for the hypothesis testing (null and alternative hypotheses) when the sample size is small and the population parameter (mean and variance) is unknown.

Top Trending Articles:
Data Analyst Interview Questions | Data Science Interview Questions | Machine Learning Applications | Big Data vs Machine Learning | Data Scientist vs Data Analyst | How to Become a Data Analyst | Data Science vs. Big Data vs. Data Analytics | What is Data Science | What is a Data Scientist | What is Data Analyst


What is a t-test?

A t-test is a statistical hypothesis test used to determine whether two sets of data have a significant difference between their means. It is used to compare the means of two groups and to determine whether there is a significant difference between them.

What types of t-tests are there?

There are two types of t-tests: the independent samples t-test and the paired samples t-test. The independent samples t-test is used when the samples are independent of each other, while the paired samples t-test is used when the samples are related.

When should I use a t-test?

A t-test is used when you want to compare the means of two groups to determine if there is a statistically significant difference between them. It is commonly used in scientific research to analyze experimental data and to determine if there is a significant effect of a treatment or intervention.

What are the assumptions of a t-test?

The assumptions of a t-test are that the data is normally distributed, the variances of the two groups are equal (for independent samples t-test), the samples are independent of each other (for independent samples t-test), and the paired observations are matched (for paired samples t-test).

How do I interpret the results of a t-test?

The results of a t-test will provide a t-value, degrees of freedom, and a p-value. The t-value measures the difference between the means of the two groups, while the p-value measures the probability of obtaining a t-value as extreme as the one observed if there is no significant difference between the groups. If the p-value is less than the significance level (usually 0.05), then we reject the null hypothesis and conclude that there is a significant difference between the two groups.

About the Author
Vikram Singh
Assistant Manager - Content

Vikram has a Postgraduate degree in Applied Mathematics, with a keen interest in Data Science and Machine Learning. He has experience of 2+ years in content creation in Mathematics, Statistics, Data Science, and Mac... Read Full Bio