Covariance Calculator

Compute sample or population covariance between two variables. Visualize the relationship with a scatter plot and understand the direction of linear dependence.

? Positive covariance (height, weight)
? Negative covariance (price, demand)
? Random uncorrelated data
Privacy first: All calculations are done locally in your browser. No data leaves your device.

What is Covariance?

Covariance measures the direction of the linear relationship between two variables. A positive covariance means that as X increases, Y tends to increase; a negative covariance means that as X increases, Y tends to decrease. The magnitude depends on the units of measurement, making it difficult to interpret directly – that’s why correlation is often used alongside.

Sample covariance:   cov(X,Y) = \frac{\sum_{i=1}^{n} (x_i - \bar{x})(y_i - \bar{y})}{n-1}

Population covariance:   cov(X,Y) = \frac{\sum_{i=1}^{n} (x_i - \mu_x)(y_i - \mu_y)}{n}

where:

  • x̄, ȳ = sample means
  • μx, μy = population means
  • n = number of paired observations

Interpreting Covariance

  • Positive: Above‑average values of X tend to pair with above‑average values of Y.
  • Negative: Above‑average X tends to pair with below‑average Y.
  • Zero: No linear trend (though non‑linear relationships may exist).

Because covariance is not scale‑invariant, its numerical value is rarely used alone. The Pearson correlation coefficient r = cov / (σx σy) normalizes the covariance to [‑1, 1] and is much easier to interpret.

Sample vs. Population Covariance

  • Sample covariance uses denominator n‑1 (Bessel’s correction) to provide an unbiased estimate of the population covariance when working with a sample.
  • Population covariance uses denominator n and assumes the data represent the entire population.
Example: Height and Weight

Consider five people with heights (cm) [160, 170, 180, 190, 200] and weights (kg) [55, 68, 72, 85, 95]. The sample covariance is positive (≈ 312.5), indicating taller people tend to weigh more. The correlation is ≈ 0.97, showing a strong linear relationship. The scatter plot clearly shows an upward trend.

Limitations of Covariance

  • Not standardized – depends on the scale of measurement.
  • Only captures linear relationships; a covariance of zero does not imply independence.
  • Sensitive to outliers.

How to Improve Interpretability

Always report both covariance and correlation. The covariance matrix is essential in multivariate statistics (e.g., PCA, linear discriminant analysis). For a deeper understanding, consider visualising the data with a scatter plot – provided below each calculation.

GetZenQuery Tech Team
This tool is developed and maintained by our in‑house analytics group. Methodologies follow established statistical standards. Last reviewed: March 2026.

All calculations run locally; no data is collected.

References:
  • DeGroot, M. H., & Schervish, M. J. (2012). Probability and Statistics (4th ed.). Pearson.
  • Wackerly, D., Mendenhall, W., & Scheaffer, R. (2008). Mathematical Statistics with Applications (7th ed.). Cengage.
  • Wikipedia: Covariance

Frequently Asked Questions

Covariance indicates the direction of a linear relationship, but its magnitude depends on the units. Correlation (Pearson's r) divides the covariance by the product of the standard deviations, resulting in a dimensionless value between -1 and 1. Correlation is easier to interpret because it measures both strength and direction.

Yes, a negative covariance means that as one variable increases, the other tends to decrease. For example, price and demand often have a negative covariance.

Use sample covariance when your data is a random sample from a larger population and you want to estimate the population covariance. Use population covariance when your data includes every member of the population (e.g., census data). Most real‑world analyses use sample covariance.

The calculator will show an error because covariance requires paired observations. Ensure both lists contain the same number of values.

This tool handles exactly two variables. For a full covariance matrix, you would need to compute pairwise covariances separately.
Answers based on standard statistical practice.