## Confidence interval for difference in means when variances are unknown and equal

Let `$x_1, x_2, \cdots, x_{n_1}$`

be a random sample of size $n_1$ from a population with mean $\mu_1$ and standard deviation $\sigma_1$.

Let `$y_1, y_2, \cdots, y_{n_2}$`

be a random sample of size $n_2$ from a population with mean $\mu_2$ and standard deviation $\sigma_2$. And the two sample are independent.

Let $\overline{x} = \frac{1}{n_1}\sum x_i$ and $\overline{y} = \frac{1}{n_2}\sum y_i$ be the sample means of first and second sample respectively.

Let $s_1^2 = \frac{1}{n_1-1}\sum (x_i -\overline{x})^2$ and $s_2^2 = \frac{1}{n_2-1}\sum (y_i -\overline{y})^2$ be the sample variances of first and second sample respectively.

Let $s_p=\sqrt{\dfrac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}}$ be the pooled standard deviation.

Let $C = 1-\alpha$ be the confidence coefficient. Our objective is to construct $100(1-\alpha)\%$ confidence interval for the difference $\mu_1-\mu_2$.

The margin of error for the difference of means is
```
$$
\begin{aligned}
E = t_{\alpha/2,n_1+n_2-2} s_p\sqrt{\frac{1}{n_1}+\frac{1}{n_2}}
\end{aligned}
$$
```

where $t_{\alpha/2,n_1+n_2-2}$ is the value from $t$ statistical table for desired confidence coefficient and degrees of freedom.

Then $100(1-\alpha)\%$ confidence interval estimate for the difference $(\mu_1-\mu_2)$ is

```
$$
\begin{aligned}
(\overline{x} -\overline{y})- E \leq (\mu_1-\mu_2) \leq (\overline{x} -\overline{y}) + E.
\end{aligned}
$$
```

## Assumptions

a. The two samples are independent.

b. Both the samples are simple random sample.

c. The two samples are both large ($n_1 > 30$ and $n_2 >30$) or both the samples comes from population having normal distribution.

d. The two population variances $\sigma^2_1$ and $\sigma^2_2$ are unknown but equal.

## Step by Step Procedure

Step by step procedure to estimate the confidence interval for difference between two population means is as follows:

### Step 1 Specify the confidence level $(1-\alpha)$

### Step 2 Given information

Given that $n_1, n_2$, $\overline{x}$, $\overline{y}$, $s^2_1$, $s^2_2$. The pooled standard deviation is $s_p=\sqrt{\dfrac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}}$.

### Step 3 Specify the formula

$100(1-\alpha)\%$ confidence interval estimate for the difference $(\mu_1-\mu_2)$ is
```
$$
\begin{aligned}
(\overline{x} -\overline{y})- E \leq (\mu_1-\mu_2) \leq (\overline{x} -\overline{y}) + E.
\end{aligned}
$$
```

where $E = t_{\alpha/2,n_1+n_2-2} s_p\sqrt{\frac{1}{n_1}+\frac{1}{n_2}}$.

### Step 4 Determine the critical value

Determine the critical value $t_{\alpha/2,n_1+n_2-2}$ from the $t$ statistical table for the desired confidence coefficient and degrees of freedom.

### Step 5 Compute the margin of error

The margin of error for the difference of means is
```
$$
\begin{aligned}
E = t_{\alpha/2,n_1+n_2-2} s_p\sqrt{\frac{1}{n_1}+\frac{1}{n_2}}\\
\end{aligned}
$$
```

### Step 6 Determine the confidence interval

$100(1-\alpha)\%$ confidence interval estimate for the difference $(\mu_1-\mu_2)$ is
```
$$
\begin{aligned}
(\overline{x} -\overline{y})- E \leq (\mu_1-\mu_2) \leq (\overline{x} -\overline{y}) + E
\end{aligned}
$$
```

Thus, $100(1-\alpha)\%$ confidence interval estimate for the difference $(\mu_1-\mu_2)$ is $\big((\overline{x} -\overline{y})- E , (\overline{x} -\overline{y}) + E\big)$.