# Two sample $t$ test for the difference in means

Assuming we have two independent samples, with the same variation, the T statistics is being constructed this way:

$$t = \frac{ (X_1 - X_2) - (\mu_1 - \mu_2) } {S_p},$$

Where by $\bar X$ is denoted the sample mean, by $\mu$ the population mean. Also, $S_p^2$ is

$$S_p^2 = \frac{ (n_1 - 1) S_1^2 + (n_2 - 1) S_2^2} {n_1 + n_2 - 2},$$

Where $S^2$ is the unbiased estimator of the variation (also referred as the sample variation), n is the population size.

$t$ has $n_1 + n_2 - 2$ DOF. My question is can we replace $S_p$ by $S_1$ or $S_2$ and get a $t$ with $n_1 - 1$ or $n_2 - 1$ DOF ? As far as I am seeing this is quite legit, as we will again get $N(0,1) / \sqrt{\chi^2(n_1-1)/(n_1-1)}.$

My other question is how are we able to construct this $t$ statistic, if the numerator and denominator are not independent?

Sorry for not being able to use MathJax properly.

• I have edited your Question with TeX, title, and tags. Please check to see that I have not changed your meaning. Also see my Answer below. If you would like to see a graphical demo (not proof) related to your second question, please ask and I will try to provide one in due course. – BruceET Oct 3 '15 at 1:08

(1) $t$ has $n_1 + n_2 - 2$ DOF. My question is whether we can replace $S_p$ by $S_1$ or $S_2$ and get a $t$ with $n_1 - 1$ or $n_2 - 1$ DOF ?
Because you are doing a 'pooled' t test, you have already assumed that the variances $\sigma_1$ and $\sigma_2$ of the two populations are equal, so we can write $\sigma_1 = \sigma_2 = \sigma.$
In that case $S_1,\, S_2\,$ and $S_p$ are all legitimate estimates of $\sigma.$ So you $could$ legitimately make the substitution you suggest and get $t$-statistics with the degrees of freedom you state. $However,$ that would be a foolish substitution because, under your assumptions, $S_p$ is the 'best' of the three estimates (being based on the most data), and it will give you more 'power' to detect a significant difference in means if such a difference exists.
(2) For normal data, the numerator and denominatorof $t$ $are\,$ (stochastically) independent. In particular, the random variables $\bar X_1$ and $S_1$ are independent. Admittedly, this is counterintuitive because $S_1$ is $functionally$ dependent on $\bar X_1$. (That is $\bar X_1$ appears in the formula for $S_1.$) Similarly $\bar X_2$ and $S_2$ are independent random variables. Finally, putting things together, the numerator and denominator of $t$ are independent.
This independence of sample mean and sample SD is true $only$ for normal data. (Not for uniform data, exponential data, or any other kind.) So it is not surprising that the result for normal data would seem strange to you. But the independence for normal data can be proved in a variety of ways (e.g., using linear algebra or using moment generating functions).