Covariance Calculator

Enter two paired data sets (X and Y) and get the sample or population covariance, the correlation coefficient r alongside, and a scatter plot with the mean-quadrants shaded to show which points push covariance up or down.

Mode:

Covariance explained, step by step

Each concept has a plain-English definition, the exact formula this calculator uses, a small diagram and a worked example — all together so the maths ties directly to the visual.

1. What covariance measures

For every point compute (xᵢ − x̄)(yᵢ − ȳ). Positive when both deviations share a sign, negative when they don't. Averaging those products gives covariance — a signed number telling you whether X and Y drift together (+), apart (−) or are unrelated (~0).

cov(X
Y) = mean of (xᵢ − x̄)(yᵢ − ȳ)
x̄, ȳmeans of X and Y·Σsum over all paired points
Example
Given
X: 2, 4, 6 · Y: 20, 24, 33
Substitute
mean of paired-deviation products
Answer
cov > 0 — X
Y rise together

2. Sample (n − 1) vs population (n)

Divide the sum of paired-deviation products by n − 1 for a sample (the usual case; Bessel's correction removes bias) or by n when the data is the entire population. The toggle on the calculator switches which divisor is applied.

sample: Σ(xᵢ − x̄)(yᵢ − ȳ) / (n − 1) · population: Σ / n
Sample
÷ (n − 1)
unbiased estimate
Population
÷ n
true parameter
Example
Given
n = 5
Σ products = 144
Substitute
sample: 144 / 4 · population: 144 / 5
Answer
cov = 36 (sample) or 28.8 (population)

3. Covariance vs correlation

Covariance carries units of X × Y, so a raw value like 36 is hard to interpret and changes if you rescale a variable. Dividing by σ_X · σ_Y strips units and produces Pearson's r in [−1, +1] — comparable across data sets, which cov cannot be.

r = cov(X
Y) / (σ_X · σ_Y)
Example
Given
cov = 36, σ_X ≈ 3.16, σ_Y ≈ 11.45
Substitute
r = 36 / (3.16 · 11.45)
Answer
r ≈ 0.995 — very strong positive

4. Reading the quadrant-shaded plot

The dashed cross on the scatter marks (x̄, ȳ). Top-right and bottom-left (green) contribute positive products; top-left and bottom-right (red) contribute negative ones. Whichever colour dominates gives the sign of covariance. Even a tight non-linear pattern (like y ≈ x²) can produce cov ≈ 0 when the four quadrants balance.

same-side product = +  ·  opposite-side
=
Example
Given
most points sit in the two green quadrants
Substitute
positive products dominate
Answer
covariance > 0

Features of this calculator

  • Sample (÷ n − 1) and population (÷ n) modes with a single toggle
  • Correlation coefficient r reported alongside so you see direction, magnitude and standardized strength in one pass
  • Quadrant-shaded scatter around (x̄, ȳ) — green pushes cov up, red pulls it down, matching the working
  • Step-by-step working: means, per-pair (xᵢ − x̄)(yᵢ − ȳ), running sum, and the final division
  • σ_X and σ_Y shown as an intermediate step so the cov → r conversion is explicit
  • Handles messy pasted input — currency symbols, thousand separators, tabs and mixed line endings all normalized
  • Copy the summary or download the entire panel (plot and steps) as an image

Frequently asked questions

+Sample or population — which should I use?

Almost always sample (n − 1). Population (n) is only correct when your data is every member of the group you care about.

+Why does the covariance number feel meaningless?

Because it carries the units of X × Y and scales with variable size. Correlation r fixes this by standardising into −1 to +1.

+Can covariance be zero for related variables?

Yes. Covariance only picks up linear co-movement. Symmetric non-linear patterns can have cov ≈ 0 while X and Y are tightly connected.

+Is cov(X, X) the same as variance?

Yes — variance is the covariance of a variable with itself: Var(X) = cov(X, X).

+Do the two lists need the same length?

Yes. Each x must be paired with the y from the same observation.

Related calculators