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.
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).
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.
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.
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.
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.