Covariance Calculator (Sample Covariance)

Calculate whether two measurements move in the same or opposite directions with the sample covariance. A scatter plot with a linear trendline is shown and the direction is interpreted from the sign of the covariance.

1Data Table

Paste a table copied from Excel into a cell (Ctrl+V). Click a column header (A, B…) before pasting to use the first line as column names. Double-click a header to rename it, right-click to insert/delete rows and columns, and formulas such as =A1*2 work too.

2Covariance Options

How to calculate covariance

  1. Copy the two columns together with the header.
  2. Select different columns for Variable X and Variable Y.
  3. Press Analyze and check the covariance and the interpretation in the statistics panel.

Worked example with sample data

The sample data are 20 pairs of process temperature (150.7-188.9 °C) and yield (68.9-85.0%).

Covariance of process temperature and yield (scatter plot, trendline, covariance)
Covariance of process temperature and yield (scatter plot, trendline, covariance)

The covariance is 43.96, a positive value, so when the temperature is above its mean the yield also tends to be above its mean (they increase together). Its unit is '°C × %', so the size 43.96 alone cannot tell whether the relationship is strong or weak.

Converting the temperature of the same data to the °F scale (×1.8) increases the covariance to 79.12, while the relationship stays the same. Dividing the covariance by the two standard deviations (10.56 °C, 4.726%) gives the unit-free Pearson r = 0.8803, which is what you use to compare strength.

How it is calculated

The sample covariance is Σ(x - x̄)(y - ȳ) / (n - 1) (the same as Excel's COVARIANCE.S and numpy's cov). Rows where X or Y is blank or text are dropped, and at least 3 valid pairs are needed.

Covariance and correlation

Dividing the covariance by the standard deviations of X and Y gives the Pearson correlation r. Covariance is measured in 'X units × Y units', so its size alone cannot compare the strength of relationships - use it for the direction (sign), and compare strength with the correlation coefficient.

How to read covariance

  • A positive covariance means that when one variable is large the other tends to be large too (they increase together); a negative one means the opposite. Near 0 there is no clear direction.
  • Changing units (for example °C to °F, or mm to μm) changes the size of the covariance. Do not compare covariance sizes across different pairs of variables.
  • Covariance is the basic ingredient of multivariate analysis (principal component analysis, covariance matrices). To look at many variables at once, use the covariance matrix.

Frequently asked questions

Is it COVARIANCE.P or COVARIANCE.S?

It divides by n-1, the sample covariance, so it equals COVARIANCE.S.

Does a large covariance mean a strong relationship?

No. Its size depends on the units. Judge strength with the Pearson correlation coefficient.

How is it related to variance?

The covariance of X with itself is the variance of X. The diagonal of a covariance matrix holds the variance of each variable.

Other chart tools