# How do I calculate the running covariance of 2 data sets? [duplicate]

This question already has an answer here:

I am writing a program that is supposed to do the linear regression of the union of two data sets, s1 and s2. I thought that if I could compute the variance and covariance of (s1 U s2) I would have the linear regression. I only have the running data for the s1 and s2. What I mean is that for each set I only have:

size , meanx , meany , variancex , covariancexy

Mean of (s1 U s2) is easy. I found a formula for calculating the variance of (s1 U s2)using the variances of the sebsets. But I can't find anything for covariance of (s1 U s2) using the covariances of s1 and s2. Is there a way to do that?

Thanks in advance.

Soroor

## marked as duplicate by whuber♦Jan 23 '18 at 19:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• The recommended solution in wikipedia is assuming that I have all of my data points. But I don't save the data points. I just keep the size, running mean, etc. as per my original post. Thanks so much for your help. – Soroor Ebnesajjad Jan 24 '18 at 4:23