Covariance CalculatorFree online math calculator — instant results, no sign-up

Calculate sample and population covariance of paired values.

Inputs

Sample covariance
5
Population covariance4

Sign in to save results and favorites.

About the Covariance Calculator

The Covariance Calculator measures how two lists of paired values vary together and reports both sample and population covariance. Each value in the first list is matched with the value in the same position in the second list. With the default lists 2, 4, 6, 8, 10 and 1, 2, 3, 4, 5, the sample covariance is 5 and the population covariance is 4.

Values
Enter the first list of numeric observations, such as 2, 4, 6, 8, 10, all expressed in the same units for that variable or as unitless values.
Paired values or weights
For covariance, enter the second list of paired observations, such as 1, 2, 3, 4, 5, in their own consistent units or as unitless values; these entries are paired values, not weights.

Formula and method

x̄ = (Σᵢ₌₁ⁿ xᵢ)/n; ȳ = (Σᵢ₌₁ⁿ yᵢ)/n; C = Σᵢ₌₁ⁿ (xᵢ − x̄)(yᵢ − ȳ); sample covariance s_xy = C/(n − 1); population covariance σ_xy = C/n.
  • xᵢThe observation in position i in the Values list.
  • yᵢThe observation in position i in the Paired values or weights list.
  • iThe index identifying a matched pair, from 1 through n.
  • nThe number of matched pairs.
  • x̄, ȳThe arithmetic means of the first and second lists, respectively.
  • ΣSummation over all matched pairs.
  • CThe sum of the products of each pair's deviations from their respective means.
  • s_xySample covariance, calculated using the divisor n − 1.
  • σ_xyPopulation covariance, calculated using the divisor n.

Calculate each list's mean, subtract the appropriate mean from each observation, and multiply the deviations within each pair. Sum these products, then divide by n − 1 for sample covariance and by n for population covariance. For the default inputs, x̄ = 6 and ȳ = 3. The deviations are −4, −2, 0, 2, 4 and −2, −1, 0, 1, 2, giving products 8, 2, 0, 2, 8 with a sum of 20. With n = 5, sample covariance is 20/4 = 5 and population covariance is 20/5 = 4.

Worked example

These are the calculator's starting values and the results it actually produces for them.

Inputs

  • Values2, 4, 6, 8, 10
  • Paired values or weights1, 2, 3, 4, 5

Results

  • Sample covariance5
  • Population covariance4

How to use the Covariance Calculator

  1. 1Enter 2, 4, 6, 8, 10 in Values to reproduce the default example, or enter your own first list.
  2. 2Enter 1, 2, 3, 4, 5 in Paired values or weights for the default example, or enter your corresponding second list.
  3. 3Check that the lists have equal lengths and that entries in matching positions describe the same observation.
  4. 4Run the calculation to obtain both covariance outputs.
  5. 5Use the sample row when estimating covariance from a sample, or the population row when describing the complete population of interest.

Reading your result

The Sample covariance row reports the deviation-product sum divided by n − 1; its default result is 5. The Population covariance row divides the same sum by n; its default result is 4. Positive covariance means the variables tend to be above or below their means together; negative covariance means they tend to deviate in opposite directions. Zero covariance indicates no linear association, but does not rule out a nonlinear relationship. Covariance has units equal to the product of the two variables' units, so its magnitude is not a standardized measure of relationship strength.

Limitations

The calculation requires equally long numeric lists with correctly aligned pairs. Sample covariance requires at least two pairs; population covariance requires at least one pair. Missing observations must be handled consistently across both lists rather than shifting the pairing. Despite the second input's label, these formulas do not use weights. Outliers and changes in measurement units can strongly affect covariance. The sample formula is an unbiased estimator of population covariance under independent, identically distributed sampling with finite second moments. Covariance alone does not establish causation.

Common questions

Why are the default sample and population covariances different?+

Both use the same deviation-product sum of 20 from five pairs. Sample covariance divides by 5 − 1, giving 5, while population covariance divides by 5, giving 4.

Does the second input represent weights in this calculator?+

For this covariance calculation, it represents the second variable's observations. The defaults form the pairs (2, 1), (4, 2), (6, 3), (8, 4), and (10, 5); no weighting is applied.

Can I sort the two lists before calculating covariance?+

You may reorder whole pairs together without changing covariance, but sorting either list independently can change which observations are paired and produce a different, misleading result.

Do covariance values of 5 and 4 indicate a weak relationship?+

No. Covariance is not standardized, so these magnitudes cannot be labeled weak or strong on their own. In the default data, every second-list value is exactly half its paired first-list value, giving a perfect positive linear relationship despite the differing covariance outputs.

Does the calculator save my information?+

Calculations run in your browser. While signed in, inputs and results are automatically recorded in account history; saving a result creates a separate saved record.

You might also like

Results are estimates for informational purposes and are not financial, medical or legal advice.