How to combine covariance matrices? I have a data set of points in three dimensions.
I'm calculating the barycenter (mean) and $3\times3$ covariance matrix from this data set.
I store the average, the $3\times3$ matrix (where really only 6 elements are unique) and the number of points that went into this calculation. Let's call this a "measure."
Now, I do the same for a second set of points. After doing this, I want to combine the two "measures" into one measure that's as close as possible to what I would get if I were to calculate one big "measure" based on the union of all the data points.
What's the right (or least wrong) way of doing this? I know how to accurately update the mean by calculating a weighted average based on the number of points in each of the measures, but it feels wrong to do the same thing with the covariance matrix.
 A: $\newcommand{\cov}{\operatorname{cov}}$
Law of total covariance:
$$
\cov(X,Y) = \mathbb E(\cov(X,Y)\mid Z) + \cov(\mathbb E(X\mid Z), \mathbb E(Y\mid Z)).
$$
Let $Z$ be $0$ or $1$ according as the data point in question belongs to one or the other data set.  Then the two covariance matrices you've already got, which you want to combine, are the two conditional covariance matrices.  The probabilities of belonging to one data set or the other are proportional to their sizes (if you're giving every point equal weight).
So the first term above, the conditional expected value, is the appropriate weighted average of the two matrices.
PS: OK, now I'm realizing that this assumes that for each data point you can say what it's value is when it's in one of the two data sets and what it's value is when it's in the other, so that they're paired.  Maybe your data are not paired.
Still later edit: Forget pairing.  This would have been better if answered more patiently.  You've got a cloud of points $\{(x_i,y_i) : i\in I\}$, and another cloud $\{(x_i,y_i)$, $i\in J\}$, $I\cap J=\varnothing$.  You pick one member of $I\cup J$ at random, all equally probable.  That gives you an $x$ and a $y$.  So there's a covariance.  And it obeys the rule above.  However: Letting $n=I\cup J$, don't divide by $n-1$ in finding the covariances, but by $n$.  Statistics textbooks often tell students that a sample variance is
$$
\frac{1}{n-1}\sum_{i=1}^n (x_i - \bar x)^2,\text{ where }\bar x =\frac{x_1+\cdots+x_n}{n}.
$$
And maybe they don't emphasize enough that that is to be used ONLY when one is estimating a population variance by using a small sample or an i.i.d. sample to estimate the variance of a large population from which the sample was taken.  The principal reason why standard deviation is used as a measure of dispersion rather than seemingly simpler things like mean absolute deviation is that the variance of a sum of independent random variables is the sum of their variances, BUT that doesn't work if variances are defined using $n-1$ rather than $n$.
