Last blog, we discussed about the Two sample z test and found that how we can compare the population mean of two machines or product.
Similar to two sample z test , we also compare the population mean of two machines using two sample t test. Now question arises that what may be the difference of two sample z and t test
When samples size are high then we should go with two sample z test and when sample size are small, choose two sample t test.
Two sample t test can be calculated in two ways, one when both the samples have equal variance and another one with unequal variance.
Two sample t test with equal variance:

Now Sp is the pooled variance that can be calculted as :

Degree of freedom can be calculated-> n1 + n2 – 2
Let us solve one problem to get clear understanding.
Problem: In a factory, samples are extracted from the Machine A and Machine B and we have to figure it out whether Machine A and B are producing of equal mean or mean of both the machine have been changed? (95% confidence) . Sample are given below.
Machine A | Machine B |
140 | 146 |
142 | 145 |
144 | 148 |
142 | 145 |
141 | 144 |
Solution: Null Hypothesis -> Mean of Machine A =Mean of Machine B
Alternate Hypothesis: Mean of Machine A not equal to Mean of Machine B
Here we will see variance of two samples are approximately same so apply the formula of two sample t test wth equal variance. We also require mean of samples, variance of the columns to calculate the two sample t test.
Metrics | Machine A | Machine B |
Observations | 5 | 5 |
Mean | 141.8 | 145.6 |
Variance | 2.2 | 2.3 |
Pooled variance | 2.25 | |
degree of freedom | 8 | |
t critical for two tail test(95% confidence) | -2.3 and +2.3 |
Polled variance can be calulated to put the values of variance and observation in the formula and when we keep pooled variance, mean and number of observation in two sample t test formula, get :
t=-4 and t critical is given 2.3 , meaning we can reject the null hypothesis.
Mean of Machine A and B has been changed.
Two Sample t test with unequal variance:

And degree of freedom can be calculated as:

Let us solve one problem to get clear understanding.
Problem: In a factory, samples are extracted from the Machine A and Machine B and we have to figure it out whether Machine A and B are producing of equal mean or mean of both the machine have been changed? (95% confidence) . Sample are given below.
Machine A | Machine B |
140 | 134 |
142 | 152 |
144 | 167 |
142 | 140 |
141 | 130 |
Solution:
Null Hypothesis -> Mean of Machine A =Mean of Machine B
Alternate Hypothesis: Mean of Machine A not equal to Mean of Machine B
Here we will see variance of two samples are not same so apply the formula of two sample t test wth unequal variance. We also require mean of samples, variance of the columns to calculate the two sample t test.
Metrics | Machine A | Machine B |
Observations | 5 | 5 |
Mean | 141.8 | 144.6 |
Variance | 2.2 | 225.8 |
t critical for two tail test | -2.77 and +2.77 |
When we put the mean and variance in the formula defined above :
t calculated=-.41 and it is less than t critical , meaning failed to reject the null hypothesis.
Mean of Machine A and B are not changed.
0 Comments