The covariance calculator above takes two paired columns of data and returns both the sample covariance and the population covariance, along with the deviation table, the sum of products, both means, both standard deviations and the correlation coefficient the covariance turns into once it is standardised. Every intermediate figure is printed, because covariance is one of those quantities that only makes sense when you can see how it was assembled.
Arb Digital publishes it with a warning attached. Covariance is a genuine, necessary quantity — it sits inside the correlation formula, inside regression slopes, inside portfolio risk models — but as a number you read and interpret on its own, it is close to useless. The sections below explain exactly why, and the rescale field in the tool lets you demonstrate the problem to yourself in one keystroke.
What This Covariance Calculator Does
Covariance measures whether two variables move together. For each observation it takes how far X sits from its own mean and how far Y sits from its mean, multiplies those two deviations, and averages the results across all observations. When X and Y are both above their means, or both below, the product is positive. When one is above and the other below, the product is negative. Add them all up and the sign tells you the direction of the relationship.
The calculator handles both divisors. Divide the sum of products by n − 1 and you get the sample covariance, the unbiased estimate to use when your data is a sample. Divide by n and you get the population covariance, correct only when you genuinely hold every member of the population. It also prints the correlation coefficient, because that is the number you almost certainly wanted, and a rescale field that multiplies X by any factor so you can watch what happens to each figure when the units change.
How to Use It
- Paste your X values into the first box, separated however you like. Spreadsheet columns paste cleanly.
- Paste the matching Y values into the second box. Order matters absolutely: the first X pairs with the first Y, and a single missing entry shifts every pair after it.
- Choose your divisor. Sample covariance divides by n − 1 and is the right default for almost all real data. Population covariance divides by n.
- Check the pair count in the table underneath. If it is lower than you expected, the two columns had different lengths and the extras were dropped.
- Try the rescale field. Set it to 100 and look at what happens to covariance versus correlation. That single comparison is the whole argument of this page.
The Formula: How Covariance Is Calculated
Sample covariance is cov(X, Y) = Σ (xi − x̄)(yi − ȳ) ÷ (n − 1). The population version divides the same numerator by n instead. The numerator is called the sum of products of deviations, and it carries all the information — the divisor only rescales it.
The n − 1 divisor is Bessel's correction, and it exists for the same reason it appears in the sample variance formula. Deviations are measured from the sample mean rather than the true population mean, and the sample mean is by construction the point that minimises those deviations. That makes the sum of products systematically too small, and dividing by n − 1 rather than n corrects the bias. The gap is large in small samples and vanishing in big ones: with n = 5 the two divisors differ by 25%, with n = 500 by 0.2%. Our variance calculator covers the same correction for a single variable, and it is worth noting that the covariance of a variable with itself is exactly its variance.
Correlation then standardises the result: r = cov(X, Y) ÷ (sx × sy). Dividing by both standard deviations cancels the units on both sides, leaving a pure number that always falls between −1 and +1. That is the entire relationship between the two quantities, and it is why the correlation coefficient calculator is usually the tool you actually want. The NIST/SEMATECH e-Handbook chapter on exploratory data analysis sets out both definitions alongside the diagnostic plots that should accompany them.
A Worked Example You Can Check Yourself
The calculator loads with X = 2, 4, 6, 8, 10 and Y = 3, 7, 5, 11, 14. The mean of X is 30 ÷ 5 = 6 and the mean of Y is 40 ÷ 5 = 8. The X deviations are −4, −2, 0, 2, 4 and the Y deviations are −5, −1, −3, 3, 6.
Multiply them pair by pair: (−4)(−5) = 20, (−2)(−1) = 2, (0)(−3) = 0, (2)(3) = 6, (4)(6) = 24. The sum of products is 20 + 2 + 0 + 6 + 24 = 52. Divide by n − 1 = 4 and the sample covariance is 13. Divide by n = 5 and the population covariance is 10.4. Both figures come out of five multiplications you can do on paper.
The correlation follows from the same table. The squared X deviations sum to 16 + 4 + 0 + 4 + 16 = 40, so the sample variance of X is 10 and its standard deviation is √10 = 3.162278. The squared Y deviations sum to 25 + 1 + 9 + 9 + 36 = 80, giving a variance of 20 and a standard deviation of √20 = 4.472136. Then r = 13 ÷ (3.162278 × 4.472136) = 13 ÷ 14.142136 = 0.919239. Those are precisely the values the tool prints, and the whole chain is reproducible with a pocket calculator.
Why Covariance Alone Is Nearly Useless
Here is the problem in one sentence: covariance is measured in the product of the two variables' units, so its size depends on units you chose arbitrarily rather than on the strength of the relationship.
Use the rescale field to see it. Multiply X by 100 — the same measurements converted from metres to centimetres, or from thousands of dollars to tens of dollars. The sample covariance jumps from 13 to 1,300. Nothing about the underlying relationship changed. Not one data point moved relative to any other. Only the label on the axis changed, and the covariance multiplied by exactly the same factor, because it is measured in X-units times Y-units.
This has two consequences that trip people up constantly. First, a covariance of 13 is neither big nor small, because there is no scale to judge it against. It could describe an almost perfect relationship between two small-valued variables or a barely detectable one between two large-valued ones. Second, you cannot compare covariances across different pairs of variables. A covariance of 1,300 between ad spend in dollars and revenue in dollars says nothing about whether that relationship is stronger than a covariance of 0.4 between click-through rate and bounce rate, both of which are proportions.
Correlation fixes both problems by dividing out both standard deviations. In the worked example, r = 0.919 regardless of whether X is in metres or centimetres — try it, the rescale field leaves the correlation untouched. That bounded, unit-free number is comparable across variable pairs and interpretable on its own. This is why covariance almost never appears in a report while correlation appears in every one.
So Why Compute Covariance at All
Because it is the engine inside things you do care about. The correlation coefficient is covariance divided by two standard deviations, so it cannot exist without it. The slope of a simple linear regression is covariance divided by the variance of X, which is why the linear regression calculator computes the same sum of products internally. In portfolio theory the variance of a combination of assets depends on the covariance between them, not on their individual variances alone — that is the mathematical basis of diversification.
Covariance also keeps its units for a reason. Because it is not normalised, it retains information about magnitude that correlation deliberately discards. Two variable pairs can have identical correlations of 0.9 while one involves swings of thousands of units and the other swings of fractions. When the size of the co-movement matters and not just its consistency, the unstandardised quantity is the one carrying that information.
The practical rule is simple. Use covariance when it is an intermediate step in a larger calculation. Use correlation when a human is going to read the number and draw a conclusion from it.
What the Sign Tells You and What It Hides
A positive covariance means the variables tend to move in the same direction; negative means opposite; near zero means no consistent linear co-movement. That last phrase carries a great deal of weight, because covariance detects linear association only.
Take a perfect U-shaped relationship — X values of −2, −1, 0, 1, 2 with Y values of 4, 1, 0, 1, 4, which is exactly Y = X². Y is completely determined by X, with no randomness whatsoever. The covariance is exactly zero, because the negative products on the left half cancel the positive ones on the right. A covariance of zero does not mean the variables are unrelated. It means no straight line captures the relationship, which is a much narrower claim.
Outliers cut the other way. Because deviations are multiplied, a single point far from both means contributes an enormous product and can dominate the entire sum. One unusual observation can flip a covariance from negative to positive on its own. Screening the columns with our interquartile range calculator before computing anything catches most of these. Plotting the pairs, even roughly, catches the rest — and both curved relationships and outlier-driven ones are obvious on a scatter plot and invisible in a single summary number. The Penn State Eberly College of Science statistics courses work through the properties of covariance and the cases where it misleads.
Arb Digital builds analytics setups that connect spend, traffic and conversions cleanly, so the relationships you measure reflect the business rather than an artefact of the tracking.
Browse All Free Tools Talk To Arb DigitalCommon Mistakes to Avoid
- Interpreting the size of a covariance — the magnitude depends on the units you happened to measure in, so it carries no information about strength on its own.
- Comparing covariances between different variable pairs — they are in different units entirely, which makes the comparison meaningless. Compare correlations instead.
- Using n instead of n − 1 for sample data — the population divisor understates covariance, and in small samples the difference is large.
- Reading a covariance near zero as no relationship — it means no linear relationship. A perfect parabolic relationship has a covariance of exactly zero.
- Mismatching the pairs — one missing value shifts every subsequent pair, which usually produces a plausible-looking but entirely wrong answer rather than an obvious error.
Related Free Tools From Arb Digital
The standardised version of this calculation lives in the correlation coefficient calculator, which is what you want in almost every reporting context. Fit a line through the same paired data with the linear regression calculator, get the spread of a single variable from the variance calculator or the standard deviation calculator, and screen for the outliers that distort covariance with the interquartile range calculator. The free online tools hub lists everything.
Frequently Asked Questions
It measures whether two variables move together. For each observation you multiply how far X is from its mean by how far Y is from its mean, then average those products. A positive result means the variables tend to rise and fall together; a negative result means they move in opposite directions.
Correlation is covariance divided by both standard deviations. That division cancels the units and forces the result between −1 and +1, so it can be interpreted on its own and compared across different variable pairs. Covariance keeps its units and cannot.
There is no way to tell. Covariance is measured in the product of the two variables' units, so converting X from metres to centimetres multiplies it by 100 without changing the relationship at all. Only the sign is meaningful in isolation; for magnitude you need the correlation.
Divide by n − 1 when your data is a sample from a larger population, which covers nearly all real cases. Dividing by n is correct only when you hold every member of the population. The population divisor produces a biased estimate that is systematically too small.
Yes. Covariance detects linear co-movement only. A perfect parabolic relationship such as Y equal to X squared, measured symmetrically around zero, has a covariance of exactly zero even though Y is completely determined by X.
Because it is a building block. Correlation is defined in terms of it, the slope of a regression line is covariance divided by the variance of X, and portfolio risk models depend on covariances between assets. It is an excellent intermediate quantity and a poor final one.
Covariance requires matched pairs, so the extra unpaired values cannot be used. This calculator uses only as many pairs as the shorter column provides and displays the pair count, so a mismatch is visible rather than silent.
This calculator performs a statistical computation on the data you enter. A relationship between two variables is not evidence that one causes the other, and this tool cannot distinguish the two.