Covariance and Correlation are two fundamental mathematical concepts used in probability and statistics to describe how two random variables change together. Both measure relationships between variables; covariance indicates the direction of the linear relationship, while correlation indicates both direction and standardized strength.
Definition
Covariance of two random variables X and Y is the expected value of the product of their deviations from their respective means. It measures how X and Y vary together; a positive covariance indicates that when X is above its mean Y tends to be above its mean, while a negative covariance indicates opposite behaviour.


Notes on formulas:
For a vector of random variables X = (X1, X2, ..., Xk)ᵀ the covariance matrix Σ has entries Σij = Cov(Xi, Xj). The covariance matrix is symmetric and positive semi-definite.
Example dataset: X = {1, 2, 3}, Y = {2, 4, 5}.
Compute the sample covariance using the unbiased estimator (divide by n-1).
n = 3.
x̄ = (1 + 2 + 3)/3 = 2.
ȳ = (2 + 4 + 5)/3 = 11/3 ≈ 3.6667.
Deviations for X: (1-2) = -1, (2-2) = 0, (3-2) = 1.
Deviations for Y: (2-11/3) = -5/3, (4-11/3) = 1/3, (5-11/3) = 4/3.
Products of deviations: (-1)(-5/3) = 5/3, (0)(1/3) = 0, (1)(4/3) = 4/3.
Sum of products = 5/3 + 0 + 4/3 = 9/3 = 3.
Sample covariance SXY = (1/(n-1)) · 3 = (1/2) · 3 = 1.5.

Definition
Correlation quantifies the strength and direction of a linear relationship between two variables. The most common measure is the Pearson correlation coefficient, which is the covariance normalised by the product of standard deviations, making it dimensionless and bounded between -1 and +1.

Interpretation
Using X = {1,2,3} and Y = {2,4,5} and the covariance computed earlier SXY = 1.5.
Compute the sample standard deviation sX.
Variance of X (sample) sX2 = (1/(n-1)) Σ (xi - x̄)2.
Deviations squared for X: (-1)2 = 1, 02 = 0, 12 = 1.
Sum = 2.
sX2 = 2/(3-1) = 1, so sX = 1.
Compute sY.
Deviations for Y previously: -5/3, 1/3, 4/3.
Squared deviations: (25/9), (1/9), (16/9).
Sum = 42/9 = 14/3.
sY2 = (14/3)/(3-1) = (14/3)/2 = 7/3 ≈ 2.3333, so sY ≈ √(7/3) ≈ 1.5275.
Sample correlation r = SXY / (sX sY) = 1.5 / (1 · 1.5275) ≈ 0.982.
This indicates a very strong positive linear relationship for the given small sample.


Direct comparisons
Civil Engineering (CE): Covariance and correlation are used in reliability analysis, structural health monitoring, geotechnical data analysis and in the assessment of correlated loads and material properties.
Computer Science Engineering (CSE): Correlation is used in feature selection for machine learning, principal component analysis for dimensionality reduction, signal processing and pattern recognition.
Electrical Engineering (EE): Covariance and correlation are central to signal processing, estimation theory (Wiener filter, Kalman filter), antenna array processing and analysis of stochastic signals and noise.
Covariance and correlation both describe relationships between two variables. Covariance provides a measure in original units and indicates direction; correlation standardises this measure to a dimensionless index between -1 and +1 indicating both direction and relative strength. Both concepts are widely used across engineering disciplines for analysis, modelling and inference; choice between them depends on whether scale matters and whether comparison across different variable pairs is required.