Covariance and Correlation

Covariance measures how two random variables vary together. Correlation normalizes covariance so the scale is easier to compare.

For random variables and :

The correlation coefficient is:

where:

The empirical covariance from paired samples is:

where:

Vector Case

For a random vector with mean , the covariance matrix is:

The diagonal entries are variances. Off-diagonal entries describe pairwise covariance.

The sample covariance matrix is:

For centered data matrix :

This connects covariance directly to eigenvalue decomposition and singular value decomposition.

Correlation Matrix

If is the diagonal matrix of feature standard deviations, the correlation matrix is:

Correlation is useful when feature scales are arbitrary, but it can hide absolute variance differences that matter for optimization or measurement noise.

Whitening

Whitening transforms features so their covariance is close to identity:

Then:

In practice, may be regularized:

Whitening can help analysis, but it can also amplify noise in low-variance directions.

Representation Analysis

Embedding covariance is often used to detect collapse or redundancy. If all embeddings become similar, the covariance spectrum becomes low-rank:

where are eigenvalues of . This can indicate that a representation has lost useful degrees of freedom.

Why It Matters

  • Dimensionality reduction often studies covariance structure.
  • Feature correlation can make linear models unstable.
  • Evaluation results can be misleading when samples are not independent.
  • Representation analysis often compares embedding covariance or collapse.
  • Covariance assumptions appear in Gaussian models, uncertainty estimates, and whitening.

Watch For

  • Correlation is not causation.
  • Zero covariance does not always mean independence.
  • Strong correlation can be an artifact of leakage, duplicates, or confounders.
  • Covariance depends on scale; correlation removes scale but not bias.
  • Pairwise correlation can miss nonlinear dependence.
  • Dataset shift can change covariance even when means look stable.
  • High correlation between features can destabilize coefficient interpretation.
  • Correlation computed over pooled data can hide subgroup-specific behavior.