Covariance and correlation

Covariance and correlation
Main articles: covariance, correlation.

In probability theory and statistics, the mathematical descriptions of covariance and correlation are very similar.[1][2] Both describe the degree of similarity between two random variables or sets of random variables.

correlation \phi_{XY}  =E[ (X-E[X])(Y-E[Y])]/(\sigma_X \sigma_Y) \;
covariance \gamma_{XY} =E[ (X-E[X])\,(Y-E[Y])]

where σX and σY are the standard deviations of X and Y respectively. Notably, correlation is dimensionless while covariance is in units obtained by multiplying the units of the two variables. The covariance of a variable with itself (i.e. X = Y) is called the variance. The correlation of a variable with itself is always 1 (except in the degenerate case where the two variances are zero, in which case the correlation does not exist).

In the case of a stationary time series, both the means and variances are constant and the covariance and correlation are functions only of the difference in the indices:

cross correlation \phi_{XY}(m) =E[ (X_n-E[X])\,(Y_{n+m}-E[Y])]/(\sigma_{X} \sigma_{Y}),
cross covariance \gamma_{XY}(m)=E[ (X_n-E[X])\,(Y_{n+m}-E[Y])].

Although the values of the theoretical covariances and correlations are linked in the above way, the probability distributions of sample estimates of these quantities are not linked in any simple way and they generally need to be treated separately. These distributions depend on the joint distribution of the pair of random quantities (X,Y) when the values are assumed independent across different pairs. In the case of a time series, the distributions depend on the joint distributions of the whole time-series.