# t-test - formula and example

The t-test is used to analyze data from experiments which have two groups. It is used in order to decide whether the difference between group 1 and group 2 is real or a chance event. Another way of saying this is: the t-test is used in order to decide whether the difference between mean of group 1 and mean of group 2 is reliable. In statistical jargon we say that we test to see whether the difference is significant.

### t-test -formula

The formula for t-test is: $$t= {{\bar{X_1}-{\bar{X_2}}} \over \sqrt{{s_1}^2 \over {n_1}}+\sqrt{{s_2}^2 \over {n_2}}}$$ We read this as follows: t equals mean1 - mean 2 [(over the square root of variance1 over the number of scores -1) +(over the square root of variance2 over the number of scores -1)] $$t= {mean1-{mean2} \over square root of {{variance1\over {number of scores in group1}}}+square root of{ variance2\over{number of scores in group2}}}$$
To calculate the t, we need to first calculate the mean and the variance. The formula for the mean is $$\bar{X} ={\sum{X} \over {n}}$$ The formula for variance is $$s^2 ={\sum{({X}-{\bar{X})}}^2 \over {n-1}}$$ Examples for the calculations are given in the chapters on the mean and variance.

### t-test -practice example

A psychologist wanted to test the effects of two vitamins on hand steadiness of male teenagers, He randomly selected 12 subjects and randomly assigned them to two groups, 6 each. Group 1 received vitamin 1 for two weeks and then each subject was asked to shoot an arrow to a target. The distance from the center of the target that the arrow hit was recorded in cm The same method was followed with Group 2, each subject of which received vitamin 2. lower scores indicate better hand steadiness. The data were analyzed by using a t-test for independent groups.

Group 1 Group 2
34
35
39
30
39
40
Mean= 36.17
Variance $s^2_1$= 12.47
n1= 6
48
47
45
47
46
45
Mean= 46.33
Variance $s^2_2$= 1.22
n2= 6

Now we plug in the values of our calculation into the t formula. $$t= {{36.17-46.33}\over \sqrt{{12.47} \over {6}}+\sqrt{{1.22} \over {6}}}$$ t=7.31
df= 10
p<0.05

The final step is to go to the t table and enter at the 0.05 level with degrees of freedom 10, df-n-2, The value we find is 1.81, which is less than the value of the t we calculated t=7.31. We express this a p<0.05. We conclude that the difference between the two means is significant. This means that our finding is reliable and not a chance event.

Rate it: