Covariance and Correlation

Drag the points on the grid to observe real-time changes in deviations, covariance, and correlation.

Visual Layers

Live Statistics

Mean of X (x̄)
0.00
Mean of Y (ȳ)
0.00
Variance X (s²x)
0.00
Variance Y (s²y)
0.00
Covariance s(x,y)
0.00
Correlation Pearson's r
0.000

Mathematical Formulae

Sample Covariance ($s_{xy}$)
$$ s_{xy} = \frac{\sum_{i=1}^{n} (x_i - \bar{x})(y_i - \bar{y})}{n-1} $$

Measures joint variability. Averages the product of deviations (the colored areas) to indicate the direction of the relationship.

Pearson Correlation ($r$)
$$ r = \frac{s_{xy}}{s_x s_y} $$

Normalizes covariance using the standard deviations ($s_x, s_y$) to a strict -1 to 1 scale. Because variables physically cannot vary together more than they vary individually, the denominator ($s_x s_y$) acts as the absolute maximum mathematical limit of joint variation.

Trendline Slope ($m$)
$$ m = r \times \frac{s_y}{s_x} $$

Correlation ($r$) acts as the standardized slope. If you strip away the messiness of real-world units (by converting data to Z-scores where $s_x = 1$ and $s_y = 1$), the slope of the regression line perfectly equals $r$.

Positive Area: Point is above both means or below both means. Increases covariance.

Negative Area: Point is above one mean but below the other. Decreases covariance.