# Confidence Interval for the Difference of Two Means

 English Português Français ‎Español Italiano Nederlands

There are various ways to construct a confidence interval for the difference of two means ${\displaystyle \mu _{1}-\mu _{2}}$ depending on the assumptions one makes. Our assumptions are as follows:

• In the two populations the random variables ${\displaystyle X_{1}}$ and ${\displaystyle X_{2}}$ are normally distributed with parameters ${\displaystyle E(X_{1})=\mu _{1}}$ , ${\displaystyle E(X_{2})=\mu _{2}}$, ${\displaystyle Var(X_{1})=\sigma _{1}^{2}}$ and ${\displaystyle Var(X_{2})=\sigma _{2}^{2}}$, i.e. ${\displaystyle X_{1}\sim N(\mu _{1};\sigma _{1}^{2})}$ and ${\displaystyle X_{2}\sim N(\mu _{2};\sigma _{2}^{2})}$.
• From each population a random sample is drawn (with replacement) The sample sizes are denoted by ${\displaystyle n_{1}}$ and ${\displaystyle n_{2}}$ respectively.
• The random samples are independent of each other.

When constructing confidence intervals for the difference ${\displaystyle \mu _{1}-\mu _{2}}$ of two means one is often interested in seeing whether the value ${\displaystyle 0}$ is covered by the interval.  If ${\displaystyle \mu _{1}-\mu _{2}=0}$ is not an element of the interval, then the two populations are different at least with respect to their means. Since ${\displaystyle X_{1}}$ and ${\displaystyle X_{2}}$ are normally distributed, ${\displaystyle {\bar {x_{1}}}}$ and ${\displaystyle {\bar {x_{2}}}}$ are also normal (see chapter ). Moreover we have:

 ${\displaystyle E({\bar {X_{1}}})=\mu _{1}}$ ${\displaystyle Var({\bar {X_{1}}})=\sigma ^{2}({\bar {X_{1}}})={\frac {\sigma _{1}^{2}}{n_{1}}}}$ ${\displaystyle E({\bar {X_{2}}})=\mu _{2}}$ ${\displaystyle Var({\bar {X_{2}}})=\sigma ^{2}({\bar {X_{2}}})={\frac {\sigma _{2}^{2}}{n_{2}}}}$.

In summary ${\displaystyle {\bar {X_{1}}}\ \sim N\left(\mu _{1};{\frac {\sigma _{1}^{2}}{n_{1}}}\right)\qquad {\bar {X_{2}}}\ \sim N\left(\mu _{2};{\frac {\sigma _{2}^{2}}{n_{2}}}\right)}$ Since linear combinations of normals are normal we also have that the difference of the two sample means ${\displaystyle D={\bar {X_{1}}}-{\bar {X_{2}}}}$ is normally distributed with expectation ${\displaystyle E(D)=E({\bar {X_{1}}}-{\bar {X_{2}}})=E({\bar {X_{1}}})-E({\bar {X_{2}}})=\mu _{1}-\mu _{2}}$ and variance ${\displaystyle Var(D)=\sigma _{D}^{2}=Var({\bar {X_{1}}}-{\bar {X_{2}}})=Var({\bar {X_{1}}})+Var({\bar {X_{2}}})={\frac {\sigma _{1}^{2}}{n_{1}}}+{\frac {\sigma _{2}^{2}}{n_{2}}}\,.}$ The standardized random variable ${\displaystyle z={\frac {D-E(D)}{\sigma _{D}}}={\frac {({\bar {X_{1}}}-{\bar {X_{2}}})-(\mu _{1}-\mu _{2})}{\sqrt {{\frac {\sigma _{1}^{2}}{n_{1}}}+{\frac {\sigma _{2}^{2}}{n_{2}}}}}}}$ is therefore ${\displaystyle N(0;1)}$. We distinguish between two cases:

• the variances of the two populations ${\displaystyle \sigma _{1}^{2}}$ and ${\displaystyle \sigma _{2}^{2}}$ are known
• the variances of the two populations ${\displaystyle \sigma _{1}^{2}}$ and ${\displaystyle \sigma _{2}^{2}}$ are unknown

1. Case: the variances ${\displaystyle \sigma _{1}^{2}}$ and ${\displaystyle \sigma _{2}^{2}}$ of the two populations are known. If both variances ${\displaystyle \sigma _{1}^{2}}$ and ${\displaystyle \sigma _{2}^{2}}$ known, we have the confidence interval ${\displaystyle \left[({\bar {X_{1}}}-{\bar {X_{2}}})-z_{1-{\frac {\alpha }{2}}}{\sqrt {{\frac {\sigma _{1}^{2}}{n_{1}}}+{\frac {\sigma _{2}^{2}}{n_{2}}}}},\,\,\,\ \,({\bar {X_{1}}}-{\bar {X_{2}}})+z_{1-{\frac {\alpha }{2}}}{\sqrt {{\frac {\sigma _{1}^{2}}{n_{1}}}+{\frac {\sigma _{2}^{2}}{n_{2}}}}}\right]}$ for the difference ${\displaystyle \mu _{1}-\mu _{2}}$ at confidence level  ${\displaystyle 1-\alpha }$;  i.e., ${\displaystyle P\left(({\bar {X_{1}}}-{\bar {X_{2}}})-z_{1-{\frac {\alpha }{2}}}{\sqrt {{\frac {\sigma _{1}^{2}}{n_{1}}}+{\frac {\sigma _{2}^{2}}{n_{2}}}}}\leq \mu _{1}-\mu _{2}\leq ({\bar {X_{1}}}-{\bar {X_{2}}})+z_{1-{\frac {\alpha }{2}}}{\sqrt {{\frac {\sigma _{1}^{2}}{n_{1}}}+{\frac {\sigma _{2}^{2}}{n_{2}}}}}\right)=1-\alpha \,.}$

• By construction these confidence intervals assign equal probability mass to the tails: ${\displaystyle P\left(\mu _{1}-\mu _{2}
• The confidence interval is symmetric around the estimated difference ${\displaystyle D}$;
• The length of the interval is constant given ${\displaystyle n_{1}}$ and ${\displaystyle n_{2}}$, the variances ${\displaystyle \sigma _{1}^{2}}$ and ${\displaystyle \sigma _{2}^{2}}$ and the confidence level ${\displaystyle 1-\alpha }$.
If we cannot assume the populations to be normally distributed, but the two sample sizes ${\displaystyle n_{1}\geq 30}$ and ${\displaystyle n_{2}\geq 30}$,  the central limit theorem may be used to justify the same confidence interval procedure.  In this case, the confidence level is approximately ${\displaystyle 1-\alpha }$.

2. Case: The variances ${\displaystyle \sigma _{1}^{2}}$ and ${\displaystyle \sigma _{2}^{2}}$ of the two populations are unknown. In this case ${\displaystyle \sigma _{1}^{2}}$ and ${\displaystyle \sigma _{2}^{2}}$ are estimated using the unbiased and consistent estimators ${\displaystyle s_{1}^{2}={\frac {1}{n_{1}-1}}\sum \limits _{i=1}^{n_{1}}(x_{1i}-{\bar {x_{1}}})^{2}\,\qquad s_{2}^{2}={\frac {1}{n_{2}-1}}\sum \limits _{i=1}^{n_{2}}(x_{2i}-{\bar {x_{2}}})^{2}}$ If we can assume variance homogeneity , i.e. ${\displaystyle \sigma _{1}^{2}=\sigma _{2}^{2}}$, one may produce an estimate ${\displaystyle s^{2}}$ for the joint variance ${\displaystyle \sigma ^{2}}$. This is the weighted arithmetic mean of the two sample variances: ${\displaystyle s^{2}={\frac {(n_{1}-1)s_{1}^{2}+(n_{2}-1)s_{2}^{2}}{n_{1}+n_{2}-2}}}$ ${\displaystyle s^{2}}$ is also called a pooled variance. The estimator ${\displaystyle s_{D}^{2}}$ for ${\displaystyle \sigma _{D}^{2}}$ is hence: ${\displaystyle s_{D}^{2}=s^{2}\left({\frac {1}{n_{1}}}+{\frac {1}{n_{2}}}\right)={\frac {n_{1}+n_{2}}{n_{1}n_{2}}}{\frac {(n_{1}-1)s_{1}^{2}+(n_{2}-1)s_{2}^{2}}{n_{1}+n_{2}-2}}\,.}$ The standard deviation ${\displaystyle s_{D}}$ – the square root of ${\displaystyle s_{D}^{2}}$ – is used to standardize. The resulting random variable ${\displaystyle t={\frac {D-E(D)}{s_{D}}}={\frac {({\bar {x_{1}}}-{\bar {x_{2}}}-(\mu _{1}-\mu _{2})}{\sqrt {{\frac {n_{1}+n_{2}}{n_{1}n_{2}}}{\frac {(n_{1}-1)s_{1}^{2}+(n_{2}-1)s_{2}^{2}}{n_{1}+n_{2}-2}}}}}}$ is t-distributed with ${\displaystyle \ n_{1}+n_{2}-2}$ degrees of freedom. We may now construct a confidence interval for the difference ${\displaystyle \mu _{1}-\mu _{2}}$: ${\displaystyle \left[({\bar {x}}_{1}-{\bar {x}}_{2})-t_{n_{1}+n_{2}-2;1-{\frac {\alpha }{2}}}s_{D}\,,\,\,\,\,\,({\bar {x}}_{1}-{\bar {x}}_{2})+t_{n_{1}+n_{2}-2;1-{\frac {\alpha }{2}}}s_{D}\right]}$ at a confidence level ${\displaystyle (1-\alpha )}$: ${\displaystyle P\left(({\bar {x}}_{1}-{\bar {x}}_{2})-t_{n_{1}+n_{2}-2;1-{\frac {\alpha }{2}}}s_{D}\,\,\,\leq \,\,\,\mu _{1}-\mu _{2}\,\,\,\leq \,\,\,({\bar {x}}_{1}-{\bar {x}}_{2})+t_{n_{1}+n_{2}-2;1-{\frac {\alpha }{2}}}s_{D}\right)\approx 1-\alpha \,.}$ If one has variance heterogeneity, i.e., ${\displaystyle \sigma _{1}^{2}\neq \sigma _{2}^{2}}$,  we use the estimator ${\displaystyle s_{D}^{2}}$ of ${\displaystyle \sigma _{D}^{2}}$ given by: ${\displaystyle s_{D}^{2}={\frac {s_{1}^{2}}{n_{1}}}+{\frac {s_{2}^{2}}{n_{2}}}}$ If the two sample sizes are sufficiently large (${\displaystyle n_{1}>30}$ and ${\displaystyle n_{2}>30}$), then we may use ${\displaystyle \left[({\bar {x}}_{1}-{\bar {x}}_{2})-z_{1-{\frac {\alpha }{2}}}\,{\sqrt {{\frac {s_{1}^{2}}{n_{1}}}+{\frac {s_{2}^{2}}{n_{2}}}}},\,\,\,\,\,({\bar {x}}_{1}-{\bar {x}}_{2})+z_{1-{\frac {\alpha }{2}}}{\sqrt {{\frac {s_{1}^{2}}{n_{1}}}+{\frac {s_{2}^{2}}{n_{2}}}}}\right]}$ for the confidence interval at level ${\displaystyle (1-\alpha )}$, i.e., ${\displaystyle P\left(({\bar {x}}_{1}-{\bar {x}}_{2})-z_{1-{\frac {\alpha }{2}}}\,{\sqrt {{\frac {s_{1}^{2}}{n_{1}}}+{\frac {s_{2}^{2}}{n_{2}}}}}\,\,\,\leq \,\,\,\mu _{1}-\mu _{2}\,\,\,\leq \,\,\,({\bar {x}}_{1}-{\bar {x}}_{2})+z_{1-{\frac {\alpha }{2}}}\,{\sqrt {{\frac {s_{1}^{2}}{n_{1}}}+{\frac {s_{2}^{2}}{n_{2}}}}}\right)=1-\alpha \,.}$

• By construction these confidence intervals assign equal probability mass to the tails.
• The confidence interval is symmetric around the ${\displaystyle {\bar {x}}_{1}-{\bar {x}}_{2}}$.
• The length of the confidence interval is random since it depends on ${\displaystyle s_{1}^{2}}$ and ${\displaystyle s_{2}^{2}}$.
• The confidence interval also depends on the sample sizes ${\displaystyle n_{1}}$ and ${\displaystyle n_{2}}$ and on the confidence level ${\displaystyle 1-\alpha }$.

We are given a population of ${\displaystyle N=3100}$ cars produced by Speed, Eco, Space and Run. We measure the following variables:${\displaystyle X1}$ = gas consumption per 100 km for cars produced by Speed${\displaystyle X2}$ = gas consumption per 100 km for cars produced by Eco${\displaystyle X3}$ = gas consumption per 100 km for cars produced by Space${\displaystyle X4}$ = gas consumption per 100 km for cars produced by RunMeans and variances are unknown. We would like to assess differences in mean gas consumption between pairs of companies. For a given random sample from two companies, find a point and interval estimate for the unknown difference of the means ${\displaystyle \mu _{1}}$ and ${\displaystyle \mu _{2}}$. Assume that variances are heterogeneous and that the populations are normally distributed. You will be able to examine the effect of the confidence level and sample size on the length of the confidence interval. We recommend that only one of these features be altered at a time. Please select

• the pair of companies to be analyzed
• the sample sizes ${\displaystyle n_{1}}$and ${\displaystyle n_{2}}$
• the confidence level ${\displaystyle 1-\alpha }$ (as decimal number, i.e. 0.95)

Results:This interactive example will provide:

1. a confidence interval for the selected confidence level

If you repeatedly draw data on the same pair of companies, but select different confidence levels/sample sizes, previous results will continue to be displayed for comparison purposes.

Company X wants to analyze its share performance on two stock exchanges using the spot price which is observed daily at 12.00 p.m. The company is particularly interested in the difference of mean spot prices. We will construct both a point estimate and a confidence interval at level ${\displaystyle 1-\alpha =0.95}$. The random variables are: ${\displaystyle X_{1}}$ - the spot price on the first stock exchange${\displaystyle X_{2}}$ - the spot price on the second stock exchangeThe means ${\displaystyle E(X_{1})=\mu _{1}}$, ${\displaystyle E(X_{2})=\mu _{2}}$ and variances ${\displaystyle Var(X_{1})=\sigma _{1}^{2}}$ , ${\displaystyle Var(X_{2})=\sigma _{2}^{2}}$ are unknown. We assume that

• prices are independent at the two stock exchanges
• the variances are equal (variance homogeneity)

We draw a random sample from each population. The sample sizes are ${\displaystyle n_{1}=10}$ and ${\displaystyle n_{2}=10}$. Since the company X has been traded at the two stock exchanges for a long time, both populations are large. Hence we can assume that we are sampling with replacement. Moreover we assume independence of the two samples. In demonstrating the construction of confidence intervals for the difference ${\displaystyle \mu _{1}-\mu _{2}}$, consider the following two cases:

• ${\displaystyle X_{1}}$ and ${\displaystyle X_{2}}$ are normally distributed
• the distributions of ${\displaystyle X_{1}}$ and ${\displaystyle X_{2}}$ are unknown

1. Case: We have ${\displaystyle X_{1}\sim N(\mu _{1};\sigma ^{2})}$ and ${\displaystyle X_{2}\sim N(\mu _{2};\sigma ^{2})}$. The standardized random variable ${\displaystyle t={\frac {D-E(D)}{s_{D}}}={\frac {({\bar {x}}_{1}-{\bar {x}}_{2})-(\mu _{1}-\mu _{2})}{\sqrt {{\frac {n_{1}+n_{2}}{n_{1}n_{2}}}\cdot {\frac {(n_{1}-1)s_{1}^{2}+(n_{2}-1)s_{2}^{2}}{n_{1}+n_{2}-2}}}}}\,,}$ is t-distributed with ${\displaystyle n_{1}+n_{2}-2=18}$ degrees of freedom. Under these assumptions ${\displaystyle \left[({\bar {x}}_{1}-{\bar {x}}_{2})-t_{n_{1}+n_{2}-2;1-{\frac {\alpha }{2}}}s_{D},\,\,\,;\,({\bar {x}}_{1}-{\bar {x}}_{2})+t_{n_{1}+n_{2}-2;1-{\frac {\alpha }{2}}}s_{D}\right]}$ is a confidence interval for the difference of the two of spot price means ${\displaystyle \mu _{1}-\mu _{2}}$ at a confidence level ${\displaystyle P\left(({\bar {x}}_{1}-{\bar {x}}_{2})-t_{n_{1}+n_{2}-2;1-{\frac {\alpha }{2}}}s_{D}\,\,\,\leq \,\,\,\mu _{1}-\mu _{2}\,\,\,\leq \,\,\,({\bar {x}}_{1}-{\bar {x}}_{2})+t_{n_{1}+n_{2}-2;1-{\frac {\alpha }{2}}}s_{D}\right)=1-\alpha =0.95\,.}$ For ${\displaystyle 1-\alpha =0.95}$, we find ${\displaystyle t_{n_{1}+n_{2}-2;1-\alpha /2}=t_{18;0.975}=2.101}$. For ${\displaystyle n=10}$ randomly selected days,  we record spot prices on each of the two exchanges (column 2 and 3). Columns 4 and 5 below contain squared deviations from the estimated means which are used to calculate the individual variances.

${\displaystyle i}$ ${\displaystyle x_{1i}}$ ${\displaystyle x_{2i}}$ ${\displaystyle (x_{1i}-{\bar {x}}_{1})^{2}}$ ${\displaystyle (x_{2i}-{\bar {x}}_{2})^{2}}$
1 18.50 18.45 0.0841 0.1296
2 19.00 18.90 0.0441 0.0081
3 18.70 18.80 0.0081 0.0001
4 19.30 19.50 0.2601 0.4761
5 17.10 17.30 2.8561 2.2801
6 18.30 18.10 0.2401 0.5041
7 18.60 18.80 0.0361 00001
8 19.00 18.85 0.0441 0.0016
9 19.40 19.50 0.3721 0.4761
10 20.00 19.90 1.4641 1.1881

We obtain: ${\displaystyle {\bar {x}}_{1}=18.79\ \qquad \qquad {\bar {x}}_{2}=18.81}$ ${\displaystyle s_{1}^{2}=0.601\qquad \qquad s_{2}^{2}=0.563\,.}$ Since we have assumed homogeneity of variances, the point estimate ${\displaystyle s^{2}}$ for the joint or pooled variance ${\displaystyle \sigma ^{2}}$ is given by the weighted arithmetic mean of the sample variances: ${\displaystyle s^{2}={\frac {(n_{1}-1)s_{1}^{2}+(n_{2}-1)s_{2}^{2}}{n_{1}+n_{2}-2}}={\frac {9\cdot 0.601+9\cdot 0.563}{18}}=0.582\,.}$ The variance of the difference of the sample means is ${\displaystyle s_{D}^{2}=s^{2}\left({\frac {1}{n_{1}}}+{\frac {1}{n_{2}}}\right)=0.582\cdot {\frac {1}{5}}=0.1164\,.}$ and the standard deviation is ${\displaystyle s_{D}=0.3412}$. A confidence interval for the difference is given by: ${\displaystyle \lbrack (18.79-18.81)-2.101\cdot 0.3412\,\ \ ,\,\ \ (18.79-18.81)+2.101\cdot 0.3412]=[-0.7369\,\ ,\,\ 0.6969]\,.}$ which is small relative to the levels of the individual spot prices. The confidence interval includes the value 0. Hence there does not appear to be an appreciable difference between the two mean spot prices ${\displaystyle \mu _{1}}$ and ${\displaystyle \mu _{2}}$. In a later chapter we will see how this implies that there is no statistically significant difference between the two prices. 2. Case: We will now drop the assumption of normality of ${\displaystyle X_{1}}$ and ${\displaystyle X_{2}}$.  We will require larger sample sizes in order that we may rely upon the central limit theorem as an approximation to the distributions of ${\displaystyle {\bar {x}}_{1}}$ and ${\displaystyle {\bar {x}}_{2}}$ (and their difference ${\displaystyle \ {\bar {x}}_{1}-{\bar {x}}_{2}}$).  We will draw samples of size ${\displaystyle n_{1}}$, ${\displaystyle n_{2}=50}$. The standardized random variable ${\displaystyle {\frac {D-E(D)}{s_{D}}}={\frac {({\bar {x}}_{1}-{\bar {x}}_{2})-(\mu _{1}-\mu _{2})}{\sqrt {{\frac {n_{1}+n_{2}}{n_{1}n_{2}}}\cdot {\frac {(n_{1}-1)s_{1}^{2}+(n_{2}-1)s_{2}^{2}}{n_{1}+n_{2}-2}}}}}}$ is approximately normally distributed. Under the above assumptions ${\displaystyle \left[({\bar {x}}_{1}-{\bar {x}}_{2})-z_{1-{\frac {\alpha }{2}}}s_{D},\,\,\,\,({\bar {x}}_{1}-{\bar {x}}_{2})+z_{1-{\frac {\alpha }{2}}}s_{D}\right]}$ is an approximate confidence interval for the difference ${\displaystyle \mu _{1}-\mu _{2}}$ at confidence level .95:${\displaystyle P\left(({\bar {x}}_{1}-{\bar {x}}_{2})-z_{1-{\frac {\alpha }{2}}}s_{D}\,\,\,\leq \,\,\,\mu _{1}-\mu _{2}\,\,\,\leq \,\,\,({\bar {x}}_{1}-{\bar {x}}_{2})+z_{1-{\frac {\alpha }{2}}}s_{D}\right)\approx 1-\alpha =0.95\,.}$ where ${\displaystyle z_{1-\alpha /2}=z_{0.975}=1.96}$ . Using our two samples of 50 observations each we obtain: ${\displaystyle {\bar {x}}_{1}=18.80\ \qquad \qquad s_{1}^{2}=0.5967}$${\displaystyle {\bar {x}}_{2}=18.83\ \qquad \qquad s_{2}^{2}=0.6188\,.}$ Since we assumed homogeneous variances, we estimate ${\displaystyle \sigma ^{2}}$ using ${\displaystyle s^{2}={\frac {49\cdot 0.5967+49\cdot 0.6188}{98}}=0.6078\,.}$ and ${\displaystyle s_{D}^{2}=s^{2}\left({\frac {1}{n_{1}}}+{\frac {1}{n_{2}}}\right)=0.6078\cdot {\frac {1}{25}}=0.0243\,.}$ The standard deviation is ${\displaystyle s_{D}=0.1559}$. The confidence interval is given by: ${\displaystyle \lbrack (18.80-18.83)-1.96\cdot 0.1559\,\ \ ,\,\ \ (18.80-18.83)+1.96\cdot 0.1559]=[-0.3356\,\ ,\,\ \ 0.2756]\,.}$ The interpretation follows as in case 1 above. Comparing the two approaches, one may conclude:

• The difference of the two sample means and the joint variances are approximately of the same size in both cases.
• The variance ${\displaystyle s_{D}^{2}}$ and standard deviation ${\displaystyle s_{D}}$ of the difference are much smaller in case 2 due to the larger sample size.
• The length of the confidence interval in case 2 is much smaller than in case 1.
• The confidence interval in case 2 is approximate because of the absence of exact knowledge of the underlying distributions.

An automobile club wants to compare (highway) gas consumption two similar types of cars produced by company A and B.  To assist the club, we will construct a confidence interval for the difference of the two means ${\displaystyle \mu _{1}-\mu _{2}}$ at a confidence level ${\displaystyle 1-\alpha =0.95}$. We make the following assumptions:

• It is assumed that the random variables:

${\displaystyle X_{1}}$ = gas consumption per 100 km of A type cars

${\displaystyle X_{2}}$ = gas consumption per 100 km of B type carsare normally distributed with unknown means ${\displaystyle E(X_{1})=\mu _{1}}$ and ${\displaystyle E(X_{2})=\mu _{2}}$ and unknown variances ${\displaystyle Var(X_{1})=\sigma _{1}^{2}}$ and ${\displaystyle Var(X_{2})=\sigma _{2}^{2}}$. We do not assume that variances are equal.

• We assume ${\displaystyle n_{1}\geq 30}$ and ${\displaystyle n_{2}\geq 30}$.

• The populations are large so we will perform sampling with replacement.

• We will assume all observations are independent.

The confidence interval for the difference ${\displaystyle \mu _{1}-\mu _{2}}$ can be constructed using ${\displaystyle \left[({\bar {x}}_{1}-{\bar {x}}_{2})-z_{1-{\frac {\alpha }{2}}}{\sqrt {{\frac {s_{1}^{2}}{n_{1}}}+{\frac {s_{2}^{2}}{n_{2}}}}},\,\,\,\,\,({\bar {x}}_{1}-{\bar {x}}_{2})+z_{1-{\frac {\alpha }{2}}}{\sqrt {{\frac {s_{1}^{2}}{n_{1}}}+{\frac {s_{2}^{2}}{n_{2}}}}}\right]}$ with approximate confidence level ${\displaystyle P\left(({\bar {x}}_{1}-{\bar {x}}_{2})-z_{1-{\frac {\alpha }{2}}}{\sqrt {{\frac {s_{1}^{2}}{n_{1}}}+{\frac {s_{2}^{2}}{n_{2}}}}}\,\quad \leq \quad \mu _{1}-\mu _{2}\quad \leq \quad ({\bar {x}}_{1}-{\bar {x}}_{2})+z_{1-{\frac {\alpha }{2}}}{\sqrt {{\frac {s_{1}^{2}}{n_{1}}}+{\frac {s_{2}^{2}}{n_{2}}}}}\right)=0.95\,.}$ where ${\displaystyle z_{1-\alpha /2}=1.96}$. The automobile club tests 36 cars of company A and 40 cars of company B. The following quantities are calculated (in liters per 100 kilometer, l/ 100 km) :

 ${\displaystyle {\bar {x}}_{1}}$ = 9.2 l/100 km ${\displaystyle s}$ = 0.6 l/100 km ${\displaystyle {\bar {x}}_{2}}$ = 8.4 l/100 km ${\displaystyle s}$ = 0.4 l/100 km

The confidence interval is: ${\displaystyle \left[(9.2-8.4)-1.96\cdot {\sqrt {{\frac {0.6^{2}}{36}}+{\frac {0.4^{2}}{40}}}}\,\ \ ,\,\ \ (9.2-8.4)+1.96\cdot {\sqrt {{\frac {0.6^{2}}{36}}+{\frac {0.4^{2}}{40}}}}\right]=[0.586\,\ ,\,\ 1.032]\,.}$ This interval does not cover 0.  We will see later that this implies a statistically significant difference in mean gas consumption between the two populations.