This is a subjectspecific page for Psychology students.
The ttest is very similar to a $z$test, however, you do not know the value of the population variance $\sigma^2$ and so you must use a modified version of the test above.
This is where you are only testing one sample, for example, the number of patients currently being treated with Cognitive Behavioural Therapy at a clinic. Usually you would compare your data with a known value, typically a mean that has often been previously derived from other research. You want to test the null hypothesis i.e. is the mean of the sample the same as the known mean?
\begin{equation} t = \dfrac{\bar{x}\mu}{\sqrt{\dfrac{s^2}{n}}} \end{equation}
See the worked example below.
A two sample ttest compares two samples of normally distributed data. We shall look at two types of two sample ttests:
The main difference between these two tests is that the tstatistic is calculated differently.
For paired/related ttests the tstatistic is:
\begin{equation} t = \dfrac{\bar{d}}{\sqrt{\dfrac{s^2}{n}}} \end{equation}
where $\bar{d} $is the mean of the differences between the samples. You will compare the tstatistic to the critical values in a ttable on $(n  1)$ degrees of freedom. Here $s$ is the standard deviation of the differences.
Whereas for the unrelated ttest, the test statistic is:
\begin{equation} t = \dfrac{\bar{x_1}  \bar{x_2}}{\sqrt{s^2\bigg(\dfrac{1}{n_1} + \dfrac{1}{n_2}\bigg)}} \end{equation}
where the pooled standard deviation $s$ is:
\begin{equation} s =\sqrt{\dfrac{(n_1  1)s_1^2 + (n_2  1)s_2^2}{n_1 +n_2 2}} \end{equation}
where $\bar{x_1}$ and $\bar{x_2}$ are the means from the two samples, likewise $n_1$ and $n _2$ are the sample sizes and $s_1^2 \text{and } s_2^2$ are the sample variances. This test statistic you will compare to ttables on $(n_1 + n_2  2)$ degrees of freedom.
Note: for the pooled variance ttest to be appropriate you rely on the assumption that the two samples come from the same population and have equal variance. See $F$tests below to see how to test for equal variances.
Here is an example of a ttable with an explanation of what each bit means. (This is for a two tailed or paired ttest for a onetailed ttest the probabilities are halved see worked example below).
A psychologist wishes to test if people mentally perform differently in the morning compared to the afternoon. He has a group of ten students. They take a mental maths test on the morning and another test on the afternoon with different questions but of the same difficulty. The test scores are shown in the following table.
Morning Scores 
Afternoon Scores 

13 
14 
20 
19 
11 
13 
9 
11 
7 
10 
14 
17 
12 
9 
13 
16 
10 
10 
17 
19 
Perform a hypothesis test to see if there is a difference in performance between the morning and afternoon.
The type of hypothesis test we need to use here is a two sample ttest, since the population standard deviations are unknown and we have a small sample size. We need to use a paired/related ttest, since the morning and afternoon samples are the same participants.
Our hypotheses are:
\begin{align} H_0:& \mu_M = \mu_A\\ H_1:& \mu_M \neq \mu_A\\ \end{align}
where $\mu_M$ and $\mu_A$ are the mean scores of the morning and afternoon tests respectively.
This is a twotailed test, as we merely wish to know if there is a difference, but have not specified if performance is better in either the afternoon or morning.
First we need to calculate the differences between the scores and mean of these differences. We shall subtract the morning scores from the afternoon scores, and then take the average. We also need to calculate the standard deviation of our two groups.
Morning Scores 
Afternoon Scores 
Differences 

13 
14 
1 
20 
19 
1 
11 
13 
2 
9 
11 
2 
7 
10 
3 
14 
17 
3 
12 
9 
3 
13 
16 
3 
10 
10 
0 
17 
19 
2 
The mean of the differences $\bar{d}$ is \[\dfrac{1  1 +2 +2 +3 +3 3 +3 +0 +2}{10} = 1.2.\]
Also note that the mean scores for the morning and afternoon groups are $12.6$ and $13.8$ respectively. We will need to mention these in our conclusion later.
The standard deviation of the difference scores can be calculated using a calculator or in SPSS.
\begin{align} s &= 1.989\\ \end{align}
Now we can calculate our tstatistic, using the formula above. $n = 10$ as there are $10$ participants in each group.
\begin{align} t &= \dfrac{1.2}{~\sqrt{\dfrac{1.989^2}{10}~}~}\\ &= 1.908 \text{ ( 3 d.p.)}.\\ \end{align}
We can compare this to critical tvalues on $10  1 = 9$ degrees of freedom.
Since $1.908$ is less than the critical value at the $0.05$ level $(1.908<2.262)$, we can conclude that there is no evidence for a difference between afternoon and morning scores. So, mental performance is the same in the afternoon and morning. We accept $H_0$.
We would report out results in the following way:
Test scores were slightly higher in the afternoon $(\bar{X} = 13.8)$ compared to in the morning $(\bar{X}=12.6)$. However, the difference did not support the hypothesis that the tests scores differ in the morning and afternoon at the $0.05$ level of significance $(t = 1.908, \text{df} = 9, p >0.05)$.
Note: df means degrees of freedom.
We can also perform this test in SPSS. To see how, watch the video tutorial below. As you can see, we get the same results as when we performed the test by hand.
You wish to test if the emotionality scores are different between two groups of schoolchildren. One group comes from twoparent families, whereas the other group from oneparent families. You want to know if children from the twoparent families score higher than those from oneparent families. The table of results are below.
' Perform a hypothesis test to test if children from twoparent families score higher than those from oneparent families'
Two Parent Family 
One Parent Family 

18 
5 
13 
12 
12 
9 
17 
11 
7 
15 
11 
10 
9 
12 
15 

16 
For this example, we will use a two sample ttest, since we not know the population variances and we have sample sizes which are less than $30$.
The null hypothesis is that there is no differences in emotionality scores between the two groups, whereas the alternative hypothesis is that children from twoparent families score higher than those who are from oneparent families.
We have:
\begin{align} H_0:& \bar{x_1} = \bar{x_2}\\ H_1:& \bar{x_1} > \bar{x_2}\\ \end{align}
where $\bar{x_1}$ and $\bar{x_2}$ are the mean scores of the twoparent group and oneparent group respectively.
This is a one tailed test, as we have specified a direction of change.
To calculate our test statistic, we need to calculate the two samples' means and variances and then the pooled standard deviation.
Firstly, for the twoparent group we have,
\begin{align} \bar{x_1} &= \frac{18 + 13 + 12 + 17 + 7 + 11 + 9 + 15 + 16}{9}\\ &= 13.11 \text{ (2 d.p.)}\\ \end{align}
Using our calculator, we find the variance ${s_1}^2 = 13.861$.
For the oneparent group we have, \begin{align} \bar{x_2} &= \frac{5 + 12 + 9 + 11 + 15 + 12 + 10}{7}\\ &= 10.57 \text{ (2 d.p.)}\\ \end{align}
and ${s_2}^2 = 9.619$.
The twoparent group is of size $n_1 = 9$ and the oneparent group is of size $n_2 = 7$.
Now we can calculate $s$ the pooled standard deviation.
\begin{align} s &= \sqrt{\dfrac{(9  1) \times 13.861 + (7  1) \times 9.619}{9 + 7  2}~}\\ &= \sqrt{\dfrac{168.602}{14}~}\\ &= \sqrt{12.043}\\ &= 3.470 \text{ (3 d.p.).}\\ \end{align}
Now we can calculate our test statistic.
\begin{align} t &= \dfrac{13.11  10.57}{\sqrt{3.470^2 \times(\frac{1}{9}+\frac{1}{7})}~}\\ &= \dfrac{2.54}{\sqrt{3.058}~}\\ &= 1.452 \text{ (3 d.p.).}\\ \end{align}
We compare it with $t$values at the $(1  \alpha)%$ significance levels on $9 + 7  2 = 14$ degrees of freedom.
Significance Level 
Critical Value 

$90\% ~ (0.1)$ 
$1.345$ 
$95\% ~ (0.05)$ 
$1.761$ 
$99\%~(0.01)$ 
$2.624$ 
$1.452<1.761$, so our statistic is not statistically significant at the $5\%$ level. This means we have no evidence against $H_0$ and we can conclude that in this particular study children from twoparent families do not have higher emotionality scores.
In a report we would write:
'It has been found that emotionality scores for the twoparent group $(\bar{X} = 13.1)$ was not significantly higher than the scores for the oneparent group $(\bar{X}=10.9)$ $(t=1.452, \text{df} = 14, p > 0.05, ns)$.'
Note: df means degrees of freedom and ns means not significant.
To see how to perform the test in SPSS watch the video tutorial below.
Try our Numbas tests on parametric hypothesis tests and twosample tests.