# How to compute the confidence interval of the difference of two normal means

Let $$X_1,\ldots ,X_N,i=1,\ldots,N$$ i.i.d. $$\mathcal{N}(\mu_X,\sigma_1^2)$$ distributed random variables and $$Y_1,\ldots,Y_N,i=1,\ldots,N$$ i.i.d. $$\mathcal{N}(\mu_Y,\sigma_2^2)$$ distributed random variables. Furthermore, let $$\mathbf{X}=(X_1,\ldots,X_N)$$ be independent from $$\mathbf{Y}=(Y_1,\ldots,Y_N)$$.

Find a confidence interval of minimal length for $$\mu_X-\mu_Y$$ to the level $$1-\alpha$$.

My approach: It seems that the statistical model to be considered here is the product model with family of probability measures $$\mathcal{N}(\mu_X,\sigma_1^2)^{\otimes N}\otimes\mathcal{N}(\mu_Y,\sigma_2^2)^{\otimes N}$$ and that the confidence interval is to be constructed wrt. this family of measures. I'm not sure how to continue from here and the case of ratios of two means seems to be quite different.

How do I continue?

EDIT: By one of the comments below, I have now done the following: Observe that $$\bar{X}-\bar{Y} \sim \mathcal{N}(\mu_X-\mu_Y,\sigma^2)$$, with $$\sigma^2$$ having some ancillary and unknown (but expressible in terms of $$\sigma_1^2$$ and $$\sigma_2^2$$) value. This means that we are now dealing with the problem of finding a confidence interval for the normal distribution in the case of unknown mean and unknown variance and thus

$$C(X_1,\ldots,X_n)=(\bar{X} -t^*\sqrt{s^2/N},\bar{X} +t^*\sqrt{s^2/N})$$,

with $$t^*$$ the $$1-\alpha/2$$ quantile of the $$t_{N-1}$$ distribution and $$s^2$$ the unbiased sample variance. I would very much appreciate any feedback regarding the correctness of this.

• Start by expressing the question in terms of the distribution of $\bar X - \bar Y,$ which reduces it to a (familiar) univariate problem.
– whuber
May 24, 2021 at 15:20
• @whuber Thanks for the help, I assume you mean the respective sample means by $\bar{X},\bar{Y}$ ? May 24, 2021 at 15:31
• If you look at textbook discussions for the two-sample Welch t tests, you may find formulas for CIs for $\mu_1-\mu_2.$ I mention the Welch test because variances are unknown and different. May 24, 2021 at 15:51

Comment continued: In case you want to check your answer against computer printout for a Welch t test in R, here are fictitious data and relevant computer printout.

set.seed(2021)
x1 = rnorm(30, 50, 7)
summary(x1);  length(x1);  sd(x1)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
36.54   47.66   51.10   51.06   57.38   62.11
 30
 7.651895

x2 = rnorm(30, 40, 5)
summary(x2);  length(x2);  sd(x2)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
28.72   33.06   38.22   38.25   41.32   50.60
 30
 5.506919

t.test(x1, x2)

Welch Two Sample t-test

data:  x1 and x2
t = 7.4401, df = 52.686, p-value = 9.136e-10
alternative hypothesis:
true difference in means is not equal to 0
95 percent confidence interval:                ## <----
9.353202 16.258810
sample estimates:
mean of x mean of y
51.05916  38.25315