Calculators
Covariance Calculator
Calculate sample and population covariance from paired X and Y data locally in your browser, with means, variances, standard deviations, and Pearson r.
Enter two paired datasets with the same number of values in the same order, separated by commas, spaces, or new lines. The calculator reports sample covariance (n − 1), population covariance (n), means, variances, standard deviations, and Pearson r. Sample covariance needs at least two pairs. The calculation runs locally in your browser; your values are not uploaded or stored.
Measure how two paired variables move together.
Covariance summarizes the joint variation of paired X and Y values. With deviations dx = x − x̄ and dy = y − ȳ, the sum of cross-products is Σ(dx × dy). Sample covariance divides it by n − 1, while population covariance divides it by n. For X 1, 2, 3, 4, 5 and Y 2, 4, 5, 4, 6, the sum of cross-products is 8, sample covariance is 2, and population covariance is 1.6. A positive covariance means the variables tend to rise together, a negative covariance means one tends to rise while the other falls, and a covariance near zero means little linear co-movement. Covariance depends on the units of X and Y, so it is not a standardized strength score; Pearson r rescales the same relationship to a −1 to 1 range. Enter the same number of X and Y values, at least two and up to 10000, in the same order. Values must be finite numbers from -1000000000 to 1000000000, separated by commas, spaces, semicolons, or new lines; scientific notation is supported. Identical values in a dataset are allowed and give variance zero, while Pearson r is reported as undefined when either dataset has no variation. All calculations run locally in your browser; your values are not uploaded or stored.
Frequently Asked Questions
Everything you need to know about this tool, how it works, and privacy.
How is covariance calculated?
Subtract each variable mean from its values, multiply the paired deviations, and add the products to get the sum of cross-products. Divide that sum by n − 1 for sample covariance or by n for population covariance. For X 1, 2, 3, 4, 5 and Y 2, 4, 5, 4, 6, the sum is 8, sample covariance is 2, and population covariance is 1.6.
What is the difference between sample and population covariance?
Population covariance divides by the number of pairs and is used when your data is the entire population. Sample covariance divides by one fewer pair to reduce bias when estimating from a sample. With two pairs the sample result uses n − 1 = 1.
What does positive or negative covariance mean?
Positive covariance means X and Y tend to move in the same direction: values above the X mean tend to pair with values above the Y mean. Negative covariance means they tend to move in opposite directions. A value near zero means little linear co-movement, but covariance is not standardized, so its size depends on the units of X and Y.
Why is Pearson r also shown?
Covariance depends on measurement units, while Pearson r rescales the same relationship to a −1 to 1 range. The calculator shows r for context and reports it as undefined when either dataset has no variation. Correlation does not prove that one variable causes the other.
Which inputs are accepted?
Enter the same number of X and Y values, at least two and up to 10000, in the same order. Separate values with commas, spaces, semicolons, or new lines, and use finite numbers from -1000000000 to 1000000000. Mismatched counts, fewer than two pairs, non-numeric text, and out-of-range values show a clear error.
Are my values uploaded?
No. All calculations and copying run locally in your browser. CodeASystem does not upload or store the values you enter.