# Confidence interval of $\mu_1 - \mu_2$ of two samples

We have two samples where both is $$N(\mu_i, \sigma_i)$$, we assume that $$\sigma_1 = \sigma_2$$. From the two samples we get the follow numbers:

$$n_1 = 4, \bar{x} = 1007.25, s_1=143.66$$ and $$n_2 = 4, \bar{x}=817.25, s_2=73.627$$

Calculate the lower limit of a confidence interval for $$\mu_1 - \mu_2$$ where the confidence level is 95%.

What I've done:

I calculated $$s$$ to be: $$s=114,1471$$. Then I use t-distribution: $$\mu_1 - \mu_2 - \frac{s\cdot \lambda_{\frac{\alpha}{2}}(f)}{\sqrt{n}}$$ which gives: $$1007.25 - 817.75 - \frac{s\cdot \lambda_{0.025}(6)}{\sqrt{8}} = 90.123$$ which apparently is wrong. What am I doing wrong here?

The thing I feel most uncertain about here is what $$f$$ and $$n$$ is supposed to be when using two samples like this.

• Usual option is to use Fisher's t statistic as a pivot, which is what the answer below suggests. – StubbornAtom May 21 '19 at 10:29

As we are dealing with unknown population variances, we need to first calculate the sample pooled variance, denoted by $$s_p^2=\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}$$ where the denominator is just the sum of $$(n_1-1)$$ and $$(n_2-1)$$. You can think of it as a weighted sum of the sample variances, $$s_1$$ and $$s_2$$.

Once this is calculated, the standard error is immediately $$\text{s.e.}=s_p\sqrt{\frac1{n_1}+\frac1{n_2}}$$ and you can obtain the lower limit of the $$95\%$$ confidence interval from $$(\hat{\mu_1}-\hat{\mu_2})-t_{n_1+n_2-2,0.975}\,\text{s.e.}$$

Note that $$0.975=1-\frac{0.05}2$$.

In your case where we have $$n_1=n_2$$, we get $$\text{s.e.}=\sqrt{\dfrac{s_1^2+s_2^2}{n_1}}$$.

• Why do you use that formula to calculate s.e.? I just calculated $s_p^2$ (with your notation) and figured that that $\sqrt{s_p^2}$ was what I should use (which obviously was wrong) and then divide it with $\sqrt{n}$. – gbgult May 21 '19 at 8:32
• Does it help if I instead write $\sqrt{\frac{s_p^2}{n_1}+\frac{s_p^2}{n_2}}$, and compare with the standard $\sqrt{\frac{\sigma^2}n}$ for one sample? When there are two samples with a normal distribution, we need to combine the reciprocals of the sample sizes together. – TheSimpliFire May 21 '19 at 8:34
• Ah, now I think I get it! The answer to the problem should be -8.2375 right? – gbgult May 21 '19 at 8:41
• No, I get $$(1007.25-817.25)-t_{4+4-2,0.975}\sqrt{\frac{143.66^2+73.627^2}4}=-7.508$$ – TheSimpliFire May 21 '19 at 8:47