## Two sample t test for means with unknown and unequal variances

Let `$\overline{x}_1$`

be the sample mean and $s_1$ be the sample standard deviation of a random sample of size $n_1$ from a population with mean $\mu_1$ and variance `$\sigma^2_1$`

.

Let `$\overline{x}_2$`

be the sample mean and $s_2$ be the sample standard deviation of a random sample of size $n_2$ from a population with mean $\mu_2$ and variance `$\sigma^2_2$`

.

Suppose the variances $\sigma^2_1$ and $\sigma^2_2$ are unknown and unequal.

The hypothesis testing problem can be set up as:

Situation | Hypothesis Testing Problem |
---|---|

Situation A : | $H_0: \mu_1=\mu_2$ against $H_a : \mu_1 < \mu_2$ (Left-tailed) |

Situation B : | $H_0: \mu_1=\mu_2$ against $H_a : \mu_1 > \mu_2$ (Right-tailed) |

Situation C : | $H_0: \mu_1=\mu_2$ against $H_a : \mu_1 \neq \mu_2$ (Two-tailed) |

## Formula

The test statistic for testing above hypothesis is

`$t =\frac{(\overline{x}_1-\overline{x}_2)-(\mu_1-\mu_2)}{SE(\overline{x}_1-\overline{x}_2)}=\frac{(\overline{x}_1-\overline{x}_2)-(\mu_1-\mu_2)}{\sqrt{\frac{s^2_1}{n_1}+\frac{s^2_2}{n_2}}}$`

where

`$SE(\overline{x}_1 - \overline{x}_2)=\sqrt{ \frac{s_1^2}{n_1}+ \frac{s_2^2}{n_2}}$`

is the standard error of difference between means,

The test statistic $t$ follows Students’ $t$ distribution with $\nu$ degrees of freedom, where

`$\nu = \frac{\bigg(\dfrac{s_1^2}{n_1}+\dfrac{s_2^2}{n_2}\bigg)^2}{\dfrac{s_1^4}{n_1^2(n_1-1)}+\dfrac{s_2^4}{n_2^2(n_2-1)}}$`

The value of $\nu$ can be rounded to the nearest integer.