![]() |
VOOZH | about |
The t-test is used to compare the averages of two groups to see if they are significantly different from each other. Suppose you want to compare the test scores of two groups of students:
We use a t-test to check if there is a significant difference in the average test scores between the two.
In a t-test, we start by assuming that both groups have the same average (this is called the null hypothesis). Then, we use the test to check if the difference we see is real or just due to chance. If it is not due to chance, we conclude that the groups are actually different.
There are three types of t-tests and they are categorized as dependent and independent t-tests.
One sample t-test is used for comparison of the sample mean of the data to a particularly given value. We can use this when the population standard deviation is unknown and the data is approximately normally distributed. It can be calculated as:.
Example: The weights of 25 obese people were taken before enrolling them into the nutrition camp. The population mean weight is found to be 45 kg before starting the camp. After finishing the camp for the same 25 people the sample mean was found to be 75 with a standard deviation of 25. Did the fitness camp work?
Before its implementation we should have some basic knowledge about numpy and scipy.
Output:
T-Statistic: 6.0
Critical t-value: 1.7108820799094275
P-Value: 1.703654035845048e-06
With T-value :
Significant difference. Camp had effect.
With P-value :
No significant difference. Camp had no effect.
Interpretation
The fitness camp had a significant effect on participants weights, causing a measurable change.
An Independent sample t-test commonly known as an unpaired sample t-test is used to find out if the differences found between two groups is actually significant or just a random occurrence. We can use this when:
It can be calculated using:
👁 22-Let's Take a example to understand
Researchers want to see if two teaching methods, A and B, produce different exam scores. Samples for both methods are collected independently.
Sample A (Teaching Method A): 78,84,92,88,75,80,85,90,87,79,78,84,92,88,75,80,85,90,87,79
Sample B (Teaching Method B): 82,88,75,90,78,85,88,77,92,80,82,88,75,90,78,85,88,77,92,80
Output:
T-value: -0.008275847896130646
P-Value: 0.9934425963209128
Critical t-value: 2.0280940009804502
T-test Result:
No significant difference.
P-test Result:
Fail to reject H0. No strong evidence of difference.
Interpretation
There is no statistically significant difference between exam scores of Teaching Method A and Teaching Method B.
Paired sample t-test also known as dependent sample t-test is used to find out if the difference in the mean of two samples is 0. The test is done on dependent samples usually focusing on a particular group of people or things. In this each entity is measured twice resulting in a pair of observations.
We can use this when:
It can be calculated using
Example Problem
Consider the following example. Scores (out of 25) of the subjects Math1 and Math2 are taken for a sample of 10 students. We have to perform the paired sample t-test for this data.
Math1: 4, 4, 7, 16, 20, 11, 13, 9, 11, 15
Math2: 15, 16, 14, 14, 22, 22, 23, 18, 18, 19
Output:
T-value: -4.953488372093023
P-Value: 0.0007875235561560145
Critical t-value: 2.2621571628540993
T-test:
Significant difference found.
P-test:
Fail to reject H0
There is a significant difference between Math1 and Math2 scores. The difference is unlikely due to chance.