Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If period 1 has variance v1 and period 2 has variance v2, what is the variance over period 1 and period 2? (period 1 and period 2 are the same length)

I've done some manual calculations with random numbers, and I can't seem to figure out how to calculate the variance over period 1 and period 2 from v1 and v2.

share|cite|improve this question

Using the same set up as @ChrisTaylor, we can regard the data sets $A$ and $B$ as specifying the conditional probability mass functions of a random variable $X$, with $\mu_A, \mu_B$ the conditional means and $\sigma_A^2, \sigma_B^2$ as the conditional variances. Thus, as noted by Chris,
$$\begin{align*} E[X] = \mu &= E[X\mid A]P(A) + E[X\mid B]P(B)\\ &= \frac{n_A}{n_A+n_B}\mu_A + \frac{n_B}{n_A+n_B}\mu_B \end{align*} $$ is the unconditional mean, while the unconditional variance is given by the sum of the mean of the conditional variances and the variance of the conditional means. Thus, $$\begin{align*} \text{var}(X) &= \left[\frac{n_A}{n_A+n_B}\text{var}(X\mid A) + \frac{n_B}{n_A+n_B} \text{var}(X\mid B)\right]\\ &\quad\quad\quad\quad\quad\quad\quad\quad+ \left[\frac{n_A}{n_A+n_B}(\mu_A - \mu)^2+\frac{n_B}{n_A+n_B}(\mu_B - \mu)^2\right] \\ &= \frac{n_A\sigma_A^2+n_B\sigma_B^2}{n_A + n_B} + \frac{n_An_B}{(n_A + n_B)^2}(\mu_A - \mu_B)^2 \end{align*} $$ which is essentially the result that Chris Taylor obtained though I think that he made a minor error in his calculations and got the difference of the two terms above instead of the sum.

share|cite|improve this answer
A clear explanation, easily generalizable to cases with more than two sets. – pharmine May 1 '13 at 2:57

If you only know the variances of your two sets, you can't compute the variance of the union of the two. However, if you know both the variances and the means of two sets, then there is a quick way to calculate the variance of their union.

Concretely, say you have two sets $A$ and $B$ for which you know the means $\mu_A$ and $\mu_B$ and variances $\sigma^2_A$ and $\sigma^2_B$, as well as the sizes of each set $n_A$ and $n_B$. You want to know the mean $\mu_X$ and variance $\sigma^2_X$ of the union $X=A\cup B$ of the two sets (assuming that the union is disjoint, i.e. that $A$ and $B$ don't have any elements in common).

With a little bit of scribbling and algebra, you can reveal that

$$\mu_X = \frac{n_A\mu_A + n_B\mu_B}{n_A+n_B}$$


$$\sigma^2_X = \frac{n_A\sigma^2_A + n_B\sigma^2_B}{n_A + n_B} - \frac{n_An_B}{(n_A+n_B)^2} (\mu_A - \mu_B)^2 $$

As pointed out in the answer by tards, the formula for the variance of the combined set depends explicitly on the means of the sets $A$ and $B$, not just on their variances. Moreover, you can see that adding a constant to one of the sets doesn't change the first term (the variances remain the same) but it does change the second term, because one of the means changes.

The fact that the dependence on the means enters through a term of the form $\mu_A-\mu_B$ shows you that if you added the same constant to both sets, then the overall variance would not change (just as you'd expect) because although both the means change, the effect of this change cancels out. Magic!

share|cite|improve this answer

There is no simple relationship between the variance of different periods and the variance for the entire time period.

As a simple example consider the following two data sets: {1, 2, 3} and {3, 4, 5}. The variance for these two sets of numbers is 1 whereas the overall variance is 2. Now if you were to add 1 to the second set of numbers which would result in the following set {4, 5, 6} its variance is still 1 whereas the overall variance has increased to 3.5. Thus, just knowing v1 and v2 will not be enough to compute the overall variance.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.