Skip to main content
HSCalculadora

Covariance Calculator

Find the covariance between two paired variables.

Comma-separated

Same count as X

Results update as you type.

Sample covariance
—

How it works

Covariance measures the direction of the linear relationship between two variables, telling you whether they tend to increase together or move in opposite directions. This calculator computes the sample covariance from paired x and y data. You enter the two lists, and it multiplies each pair's deviations from their respective means, sums the products, and divides by one less than the number of pairs. A positive result means that when one variable is above its average, the other tends to be above its average too, so they move together; a negative result means they move oppositely; and a value near zero means little linear relationship. Covariance is the foundation of the correlation coefficient, which standardises it to the range minus one to one, and it appears throughout finance, where the covariance of asset returns drives portfolio diversification, and in statistics, machine learning, and the sciences. Its main limitation is that its size depends on the units of the variables, so it shows direction clearly but not strength; for strength you convert it to correlation. Enter matching lists of x and y values, with the same number of entries in each, to compute the covariance.

Formula

cov = Σ(xᵢ − x̄)(yᵢ − ȳ) / (n − 1)

Covariance measures how two variables vary together. For each paired observation you multiply the deviation of x from its mean by the deviation of y from its mean, sum these products, and divide by the number of pairs minus one for a sample. A positive covariance means the variables tend to rise together, a negative one means one rises as the other falls, and zero means no linear tendency.

Source:Descriptive statistics

We review all our tools from time to time to ensure accuracy.

Worked example

X values:1, 2, 3Y values:2, 4, 6
Deviations multiply and sum to 4; covariance = 4 / (3 − 1) = 2 (positive).

How to use this calculator

  1. 1

    Enter your values

    Enter x values and y values.

  2. 2

    Adjust the options

    Fine-tune any options to match your situation.

  3. 3

    Read your result

    Sample covariance updates instantly as you type — no button to press.

Frequently asked questions

What is covariance?

Covariance is a measure of how two variables change together. A positive covariance means they tend to increase and decrease in step, while a negative covariance means one tends to rise as the other falls. It captures the direction of a linear relationship, forming the basis for correlation and appearing widely in statistics and finance.

What does the sign of covariance mean?

A positive covariance indicates the two variables move in the same direction: high values of one accompany high values of the other. A negative covariance indicates they move oppositely. A covariance close to zero suggests no consistent linear relationship. The sign is the most interpretable part of covariance, since its magnitude depends on the units of the data.

How is covariance different from correlation?

Covariance shows the direction of a relationship but its magnitude depends on the variables' units, making it hard to judge strength. Correlation standardises covariance by dividing by the product of the standard deviations, producing a value between minus one and one that measures both direction and strength on a comparable scale, regardless of units.

Why is covariance used in finance?

In portfolio theory, the covariance between the returns of different assets determines how they move relative to each other. Combining assets with low or negative covariance reduces overall portfolio risk through diversification, because losses in one may be offset by gains in another. Covariance is therefore a core input in building efficient, well-diversified investment portfolios.

Do the two lists need the same length?

Yes. Covariance is computed from paired observations, so each x value must have a corresponding y value. The calculator uses as many pairs as the shorter list provides, but for a correct result you should supply lists of equal length where each pair represents the same observation, such as one person's height and weight.