Calculators King

Regression and Correlation

Covariance Calculator

Sample covariance multiplies paired deviations, adds those products, and divides by n minus 1, and this page also prints the mean of each list.

Worksheet

Press Calculate to see the result.

Sample covariance multiplies paired deviations, adds those products, and divides by n minus 1, and this page also prints the mean of each list.

What this calculator answers

Covariance asks whether two lists step in the same direction. Each X is measured from the X mean, each Y from the Y mean, and those two distances are multiplied. A positive product average means the pairs tend to be high together or low together. The unit is the product of the two original units, so this number is not yet a correlation. The divisor is n minus 1 because the page reports the sample covariance. The page keeps the definition fixed while the ticket updates, so a hand check can match every intermediate term. The worksheet asks for X values, Y values, and it refuses a blank that the formula cannot interpret. Treat the loaded example as a rehearsal for the live numbers you will type next, not as a claim about your own data.

The page returns the sample covariance and the two means. It does not divide by the standard deviations, so it does not return Pearson r. Supporting counts and intermediate terms sit under the headline so a reader can see what was divided by what. When a checkbox or a tail setting changes the divisor or the rejection region, that choice appears in the steps rather than vanishing into a silent default.

The formula, written out

Sample covariance uses this relationship.

cov = sum((x - mean x)(y - mean y)) / (n - 1)

  • x, y. A paired observation from the two lists.
  • mean x. The arithmetic mean of the X list.
  • n - 1. The sample divisor, one less than the pair count.
  • cov. The average paired product of deviations.

The products of deviations are the whole signal. Dividing by n minus 1 matches the sample covariance used beside a sample correlation. Dividing by n would be a population version this page does not use. The algebra is the named textbook identity for this worksheet. Intermediate products and quotients appear in order so a calculator and a pencil can agree to the displayed rounding. If a neighbouring page uses a different divisor or a continuity correction, that page says so on its own ticket.

A full worked example

Example loaded in the worksheet

The form is prefilled with a small example so every arithmetic step can be checked by hand. Change one field after you finish the walkthrough and confirm the ticket moves the way the formula predicts.

There are 5 pairs, so the sample divisor is 4. The mean of X is 3 and the mean of Y is 4.4. Each pair contributes (x - 3) times (y - 4.4).

The sum of those products is 10. Divide by n minus 1: 10 / 4 = 2.5. That quotient is the sample covariance, not the population version that divides by 5.

The first pair alone is (−2)(−2.4) = 4.8. A positive result means the lists tend to be on the same side of their means together.

Figures from the worked example
Sample covariance2.5
Mean of X3
Mean of Y4.4
Pairs5

A second situation

The last Y is raised from 7 to 12

There are 5 pairs, so the sample divisor is 4. The mean of X is 3 and the mean of Y is 5.4. Each pair contributes (x - 3) times (y - 5.4).

The sum of those products is 20. Divide by n minus 1: 20 / 4 = 5. That quotient is the sample covariance, not the population version that divides by 5.

The first pair alone is (−2)(−3.4) = 6.8. A positive result means the lists tend to be on the same side of their means together.

Figures from the worked example
Sample covariance5
Mean of X3
Mean of Y5.4
Pairs5

Raising the last Y increases the products that involve that pair, so the covariance moves even though the X mean stays fixed. The second example changes the feature that this formula is sensitive to, and the ticket shows the new figure beside the same definition. That contrast is the fastest way to see which input owns the movement.

What moves when the input moves

The last Y moved from 7 to 10. The X list and the other Y values stayed put. The headline result went from 2.5 to 4.

The nudged inputs

There are 5 pairs, so the sample divisor is 4. The mean of X is 3 and the mean of Y is 5. Each pair contributes (x - 3) times (y - 5).

The sum of those products is 16. Divide by n minus 1: 16 / 4 = 4. That quotient is the sample covariance, not the population version that divides by 5.

The first pair alone is (−2)(−3) = 6. A positive result means the lists tend to be on the same side of their means together.

Figures from the worked example
Sample covariance4
Mean of X3
Mean of Y5
Pairs5

How to read the result

Read the sign first. Positive means the lists tend to move together. The size still carries the units of X times Y, so a large covariance can be a unit choice rather than a tight relationship. Say the unit, the sample size or contract terms, and the formula name in the same sentence as the figure. A number without those three pieces invites a later reader to invent a definition that this page never used.

Write the result with its unit, the inputs that produced it, and the name of the formula. Write the result with its unit, the inputs that produced it, and the name of the formula. If the ticket shows a decision sentence, quote the alpha and the tail with it. If the ticket shows a money or dose figure, quote the rate and the schedule that produced it.

Assumptions that have to stay true

  • The two lists are paired in the order typed.
  • Both lists have the same count, at least 2.
  • A blank is missing data, not a zero.
  • The sample divisor n minus 1 is the definition you want.

If an assumption above is false, do not average the discomfort away. Change the worksheet or change the question. A correct arithmetic step on the wrong model is still the wrong answer for the decision you are trying to make.

Mistakes that change the answer

  • Dividing by n and calling the result the sample covariance.
  • Pairing values after sorting each list separately.
  • Comparing covariances that were measured in different units.
  • Treating covariance as if it were already on the minus one to plus one correlation scale.

Where a different calculator is the honest choice

Use the correlation coefficient calculator when you want Pearson r on a unit-free scale. Use the line of best fit calculator when you want the slope. Use Pearson's correlation test when you want a p-value. Related links under the essay open pages that keep their own formulas instead of hiding a mode switch inside this ticket.

When the job changes, move to a page built for that job: Correlation Coefficient Calculator, Line of Best Fit Calculator, Pearson's Correlation Test Calculator.

Check yourself

X is 1, 2, 3 and Y is 2, 3, 4. What is the sample covariance?

The means are 2 and 3. The paired products are 1, 0, and 1. Their sum is 2, and dividing by 2 gives a sample covariance of 1.

Using the result in a sentence

Paired lab readings, before-and-after scores, and price-and-quantity series are the usual places a covariance is computed before a correlation. Keep the count, the unit, and the assumption list beside any copy of the number that leaves this browser tab.

Covariance has no upper bound. A change of units changes the number even when the pairing is identical. Use a correlation when you need a scale that does not depend on the units. Pair the headline with the steps before you staff a route, set a grade boundary, or compare two contracts from a single number.

Questions people ask next

01What definition does the Covariance Calculator commit to?

This page uses Sample covariance: cov = sum((x - mean x)(y - mean y)) / (n - 1). The products of deviations are the whole signal. Dividing by n minus 1 matches the sample covariance used beside a sample correlation. Dividing by n would be a population version this page does not use. If a textbook uses a different divisor, a different continuity correction, or a different rounding rule, the last digits can move, so the definition is printed above the result. The worksheet asks for X values, Y values, and it refuses a blank that the formula cannot interpret. Keep that printed definition in the sentence you write next to the figure so a later reader can rebuild the arithmetic without guessing which convention you chose.

02How should the worked example be read out loud?

In the loaded example the sample covariance is 2.5. Read the sign first. Positive means the lists tend to move together. The size still carries the units of X times Y, so a large covariance can be a unit choice rather than a tight relationship. Say the unit and the count before you say whether the number is large or small. Read the steps in order rather than jumping to the headline, because the intermediate terms are where a swapped percent and proportion usually hide. If the ticket shows both a primary figure and a comparison figure, name which one you are quoting.

03What is the fastest way to get a misleading result?

Dividing by n and calling the result the sample covariance. Covariance has no upper bound. A change of units changes the number even when the pairing is identical. Use a correlation when you need a scale that does not depend on the units. A second common failure is leaving a checkbox or tail setting in the wrong state and then treating the number as if the default had matched your plan. Reset the example, change one input, and confirm the ticket moves in the direction the formula predicts before you trust a live run.

04When should I leave this page for a different calculator?

Use the correlation coefficient calculator when you want Pearson r on a unit-free scale. Use the line of best fit calculator when you want the slope. Use Pearson's correlation test when you want a p-value. The related links under the essay go to those worksheets, which keep their own formulas instead of hiding them in a mode switch. If the question changed from a summary to a test, from a payment to a refinance, or from a raw score to a percentile, switch pages rather than forcing this ticket to answer a job it was not built for.

05What belongs in the sentence next to the number?

The means are 2 and 3. The paired products are 1, 0, and 1. Their sum is 2, and dividing by 2 gives a sample covariance of 1. Name the formula, the sample size or the inputs, and the unit before you compare the figure with someone else's. A bare number without those three pieces cannot be audited when a score, a rate, or a lab value is challenged later. Store the inputs beside the result whenever the figure will travel into a report.