Tutorials › Introduction to Statistics › Variance of a Difference Between Independent Sample Means

Two-Sample t Inference · Tutorial 724 of 996

Variance of a Difference Between Independent Sample Means

Learn why independent sample-mean variances add, how sample sizes and variances affect the result, and how to calculate the estimated standard error.

Intermediate 9 min read

What You'll Learn

  • Derive the variance of each sample mean from the variance of independent observations.
  • Use independence to find the variance of a difference between two sample means.
  • Distinguish the theoretical variance from its estimate based on sample variances.
  • Calculate the estimated standard error in context, with units.
  • Explain how each group’s sample size and variability affect the result.
  • Recognize why a dependence between groups changes the variance calculation.

Why the Difference Has Its Own Variability

When two groups are compared, the observed difference between their sample means is not usually exactly the difference between the population means. A different pair of samples would generally produce a different difference. To describe that sampling variability, we need to know how much each sample mean varies and how the two sample means vary together.

This tutorial focuses on two independent samples. The population variances do not have to be equal. The key result is that each group contributes its own variance to the variance of the difference, with the contribution divided by that group’s sample size.

Definition: For independent samples from two populations with means \(\mu_1,\mu_2\) and finite variances \(\sigma_1^2,\sigma_2^2\), the variance of the difference between the sample means is $$ \operatorname{Var}(\bar{X}_1-\bar{X}_2) = \frac{\sigma_1^2}{n_1}+\frac{\sigma_2^2}{n_2}. $$ The corresponding standard deviation is the square root of this variance. It describes the sampling variability of the difference \(\bar{X}_1-\bar{X}_2\), not the variability of individual observations.

Here \(\bar{X}_1\) and \(\bar{X}_2\) denote the sample means as random variables: their values would change across repeated samples. The observed sample means are written \(\bar{x}_1\) and \(\bar{x}_2\). Their difference, \(\bar{x}_1-\bar{x}_2\), estimates the population mean difference \(\mu_1-\mu_2\).

Deriving the Variance

Assume observations within each group are independent draws from that group’s population, and that the two samples are independent of one another. Every observation in group 1 has variance \(\sigma_1^2\), and every observation in group 2 has variance \(\sigma_2^2\). These conditions allow the variance of a sum within each sample to be calculated by adding the observation variances.

For group 1, write the sample mean as the sum of its \(n_1\) observations divided by \(n_1\). Multiplying a random variable by a constant multiplies its variance by the square of that constant. Independence means the variances of the observations add, so:

$$ \begin{aligned} \operatorname{Var}(\bar{X}_1) &=\operatorname{Var}\left(\frac{X_1+\cdots+X_{n_1}}{n_1}\right)\\ &=\frac{1}{n_1^2}\operatorname{Var}(X_1+\cdots+X_{n_1})\\ &=\frac{1}{n_1^2}\left(n_1\sigma_1^2\right)\\ &=\frac{\sigma_1^2}{n_1}. \end{aligned} $$

The same reasoning for group 2 gives \(\operatorname{Var}(\bar{X}_2)=\sigma_2^2/n_2\). For any two random variables \(A\) and \(B\), the variance of their difference is \(\operatorname{Var}(A-B)=\operatorname{Var}(A)+\operatorname{Var}(B)-2\operatorname{Cov}(A,B)\). The sample means are independent because the two samples are independent, so their covariance is zero. Substituting their variances therefore gives the result:

$$ \begin{aligned} \operatorname{Var}(\bar{X}_1-\bar{X}_2) &=\operatorname{Var}(\bar{X}_1)+\operatorname{Var}(\bar{X}_2) -2\operatorname{Cov}(\bar{X}_1,\bar{X}_2)\\ &=\frac{\sigma_1^2}{n_1}+\frac{\sigma_2^2}{n_2}. \end{aligned} $$

This derivation does not require equal population variances or equal sample sizes. It does require independence: without it, the covariance term may not be zero. The result also relies on independent observations within each group; if observations in a group are correlated, the variance of that group’s sample mean need not be \(\sigma^2/n\).

From Population Variances to an Estimated Standard Error

In practice, the population variances are usually unknown. For each group, the sample variance \(s^2\) estimates the corresponding population variance. For observations \(x_1,\ldots,x_n\), the sample variance is the average squared deviation from the sample mean using \(n-1\) in the denominator:

$$ s^2=\frac{\sum_{i=1}^{n}(x_i-\bar{x})^2}{n-1}. $$

Replacing each unknown population variance with its group’s sample variance gives an estimate of the variance of the difference. Taking the square root gives the estimated standard error, abbreviated \(SE\). The standard error is expressed in the same units as the original measurements; the variance is in squared units.

Result: For two independent samples, the estimated variance of the difference between sample means is \(s_1^2/n_1+s_2^2/n_2\). Its estimated standard error is $$ SE(\bar{x}_1-\bar{x}_2) = \sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}}. $$ This formula estimates the variability of the difference across repeated sampling. It is not the standard deviation of the observations pooled across both groups.

Each term, \(s_i^2/n_i\), is that group’s estimated contribution to the variance. A group contributes more when its observations are more variable, and contributes less when its sample size is larger. The contributions are added as variances; the square root is taken only after adding them.

Worked Example: Calculating the Standard Error From Raw Data

Suppose two independent, hypothetical samples record recovery time in minutes. Group 1 has observations 8, 10, 12, and 14; group 2 has observations 5, 7, 8, 9, and 11. Assume the samples are independent random samples from their respective populations, and observations within each sample are independent. Calculate the observed difference and its estimated standard error.

Group 1. The sample size is \(n_1=4\), and the sample mean is \(\bar{x}_1=(8+10+12+14)/4=11\) minutes. The squared deviations from 11 sum to \((8-11)^2+(10-11)^2+(12-11)^2+(14-11)^2=9+1+1+9=20\). Therefore, \(s_1^2=20/(4-1)=6.667\) minutes squared.

Group 2. The sample size is \(n_2=5\), and the sample mean is \(\bar{x}_2=(5+7+8+9+11)/5=8\) minutes. The squared deviations from 8 sum to \(9+1+0+1+9=20\), so \(s_2^2=20/(5-1)=5.000\) minutes squared.

The observed difference, group 1 minus group 2, is \(11-8=3\) minutes. Estimate the variance of this difference by dividing each sample variance by its own sample size and adding:

$$ \frac{s_1^2}{n_1}+\frac{s_2^2}{n_2} = \frac{6.667}{4}+\frac{5.000}{5} = 1.667+1.000 = 2.667\text{ minutes}^2. $$

Thus the estimated standard error is \(\sqrt{2.667}=1.633\) minutes. Under the stated independent-sampling assumptions, this estimates how much the difference in sample mean recovery times would vary across repeated pairs of samples of these sizes.

How Sample Size and Variability Contribute

The formula makes the contribution of each group visible. For example, a group with high variability can still contribute modestly if its sample size is large. Conversely, a small sample can contribute substantially even when its observations are less variable. The relevant comparison is between the ratios \(s_1^2/n_1\) and \(s_2^2/n_2\), not between the sample sizes or standard deviations considered alone.

Worked Example: Unequal Sample Sizes and Variances

In a hypothetical comparison of two independent groups, a measurement is recorded in milligrams per liter. Group 1 has \(n_1=16\) observations and sample standard deviation \(s_1=8\) mg/L. Group 2 has \(n_2=64\) observations and sample standard deviation \(s_2=4\) mg/L. Assume independent random samples, independent observations within each group, and no shared individuals between samples. Find each group’s contribution and the estimated standard error.

First square the sample standard deviations to obtain sample variances: \(s_1^2=8^2=64\) \((\text{mg/L})^2\) and \(s_2^2=4^2=16\) \((\text{mg/L})^2\).

$$ \begin{aligned} \text{Group 1 contribution}&=\frac{s_1^2}{n_1}=\frac{64}{16}=4.000\;(\text{mg/L})^2,\\ \text{Group 2 contribution}&=\frac{s_2^2}{n_2}=\frac{16}{64}=0.2500\;(\text{mg/L})^2,\\ \widehat{\operatorname{Var}}(\bar{x}_1-\bar{x}_2)&=4.000+0.2500=4.250\;(\text{mg/L})^2,\\ SE(\bar{x}_1-\bar{x}_2)&=\sqrt{4.250}=2.062\;\text{mg/L}. \end{aligned} $$

Group 1 contributes more to the estimated variance, even though its sample standard deviation is only twice group 2’s: its sample is also four times smaller. This calculation does not require the two population variances to be equal.

Increasing one sample size reduces that group’s contribution in proportion to \(1/n\), provided its variance stays the same. For instance, doubling \(n_1\) halves \(s_1^2/n_1\), not the standard error itself. The standard error is the square root of the sum of both contributions, so changing one group’s sample size does not generally halve the total standard error.

Worked Example: A Larger Contribution From a Smaller, More Variable Group

Consider hypothetical independent samples measuring a quantity in kilograms. Group 1 has \(n_1=9\) and \(s_1=3\) kg; group 2 has \(n_2=4\) and \(s_2=2\) kg. Assume independent sampling within and between the groups. Calculate the estimated variance and standard error, and identify the larger contribution.

The sample variances are \(s_1^2=9\) kg squared and \(s_2^2=4\) kg squared. Their contributions are \(9/9=1.000\) kg squared for group 1 and \(4/4=1.000\) kg squared for group 2. Thus,

$$ \widehat{\operatorname{Var}}(\bar{x}_1-\bar{x}_2) = \frac{9}{9}+\frac{4}{4} = 2.000\;\text{kg}^2, \qquad SE(\bar{x}_1-\bar{x}_2) = \sqrt{2.000} = 1.414\;\text{kg}. $$

Neither group contributes more in this example: group 1’s sample variance is larger, but its sample size is also larger. The equal contributions illustrate why both the variance and sample size must be considered together.

Independence Is Part of the Formula

The addition rule applies because the two sample means are independent. If the same individuals are measured twice, or if observations are otherwise linked, the sample means may have nonzero covariance. In that case, the general variance identity includes a covariance term:

$$ \operatorname{Var}(\bar{X}_1-\bar{X}_2) = \operatorname{Var}(\bar{X}_1)+\operatorname{Var}(\bar{X}_2) - 2\operatorname{Cov}(\bar{X}_1,\bar{X}_2). $$

A positive covariance reduces the variance of the difference relative to the independent-samples expression; a negative covariance increases it. Therefore, one should not use the independent-samples formula merely because the data are described as coming from two groups. The sampling design must support independence between the groups.

Common Mistakes

  • Adding standard deviations instead of variances. The group contributions \(s_1^2/n_1\) and \(s_2^2/n_2\) are added first; then their sum is square-rooted to obtain the standard error.
  • Using one sample size for both terms. Each group’s variance is divided by its own sample size: \(s_1^2/n_1\) and \(s_2^2/n_2\).
  • Assuming equal variances are necessary. The variance expression allows \(\sigma_1^2\) and \(\sigma_2^2\) to differ. Independence, not equality of variances, is what removes the covariance term.
  • Confusing variance with standard error. The estimated variance is in squared units, while its square root, the estimated standard error, is in the original measurement units.
  • Ignoring dependence. If the two means are based on linked or repeated observations, their covariance may matter, so the independent-samples formula may not apply.
Key takeaway: For independent samples, the variance of a difference between sample means is the sum of the two sample-mean variances. Each population variance is divided by its own sample size; in practice, sample variances replace the unknown population variances to estimate the standard error.

Check Your Understanding

Use the formulas and reasoning in this tutorial to answer the following questions.

  1. Why does the variance of a sample mean from \(n\) independent observations with population variance \(\sigma^2\) equal \(\sigma^2/n\)?
  2. For independent samples with \(n_1=25\), \(s_1=5\), \(n_2=100\), and \(s_2=10\), calculate each variance contribution and the estimated standard error. The measurements are in centimeters.
  3. Why is it incorrect to add \(s_1/\sqrt{n_1}\) and \(s_2/\sqrt{n_2}\) to obtain the standard error of the difference?
  4. Does the independent-samples variance formula require equal population variances? What assumption makes the covariance term zero?
  5. If two sample means are positively correlated, how does the covariance term affect the variance of their difference compared with the independent case?