Home › Calculators › Covariance Calculator

Covariance Calculator

Enter paired X and Y values, as x, y pairs or as two lists, to get the sample covariance (divide by n − 1) and population covariance (divide by n). Every deviation product is shown in a step table, together with the means, the correlation coefficient and a scatter plot that shows which points push the covariance up or down.

Last updated:

Covariance type
Data format

Separate x and y with a comma, space or tab. You can paste two spreadsheet columns; a header line is skipped.

Separated by commas, spaces or new lines

Enter your values to see the result.
Advertisement
Advertisement

How to use the Covariance Calculator

  1. Choose sample or population covariance. Use sample if your data is a sample from a larger group.
  2. Enter your data: one x, y pair per line, or switch to Two lists and paste each column.
  3. Press Calculate covariance; results also update as you type.
  4. Read the covariance, its sign and the correlation coefficient.
  5. Check the step table and the scatter plot, then copy the results or download the CSV.

Covariance formulas

QuantityFormulaWhen to use
Sample covariancesxy = Σ(x − x̄)(y − ȳ) ÷ (n − 1)Data is a sample from a larger group
Population covarianceσxy = Σ(x − μx)(y − μy) ÷ nData covers the whole population
Shortcut (sample)(Σxy − n·x̄·ȳ) ÷ (n − 1)Quick hand calculation from Σxy
Correlationr = sxy ÷ (sx · sy)Unit-free strength, −1 to 1

Worked example

Take the pairs (1, 2), (2, 4), (3, 5), (4, 4), (5, 5). The means are x̄ = 15 ÷ 5 = 3 and ȳ = 20 ÷ 5 = 4.

xyx − x̄y − ȳ(x − x̄)(y − ȳ)
12−2−24
24−100
35010
44100
55212
Sum6

Sample covariance = 6 ÷ (5 − 1) = 1.5. Population covariance = 6 ÷ 5 = 1.2. Both are positive, so larger x values go with larger y values.

Reading the result

  • Sign matters most. Positive means the variables rise together, negative means one rises as the other falls.
  • Size depends on units. Covariance of height in centimeters and weight in kilograms is 100 times larger than with height in meters, so compare strength with the correlation r instead.
  • Outliers have a big effect. One point far from both means adds a large product to the sum; look at the step table to spot it.
  • Linear only. Covariance near zero does not prove the variables are unrelated, only that there is no straight-line trend.

Frequently asked questions

What is covariance?

Covariance measures how two variables move together. If Y tends to be above its mean when X is above its mean, the covariance is positive; if Y tends to be below its mean when X is above, it is negative; if there is no linear pattern, it is near zero.

What is the covariance formula?

Sample covariance is cov(X, Y) = Σ(x − x̄)(y − ȳ) ÷ (n − 1). Population covariance uses the same sum divided by n. Here x̄ and ȳ are the means and n is the number of pairs.

Should I use sample or population covariance?

Use population covariance when your data includes every member of the group you care about. Use sample covariance, which divides by n − 1, when the data is a sample used to estimate the covariance of a larger population; the n − 1 (Bessel's correction) removes the bias of using the sample means.

What is the difference between covariance and correlation?

Covariance depends on the units of X and Y, so its size is hard to interpret: changing meters to centimeters multiplies it by 100. Correlation divides the covariance by both standard deviations, giving a unit-free number from −1 to 1 that shows the strength of the linear relationship.

Can covariance be negative?

Yes. A negative covariance means the variables tend to move in opposite directions, for example outdoor temperature and hot drinks sold. Covariance has no fixed range; it can be any positive or negative number.

What does a covariance of zero mean?

It means there is no linear relationship between X and Y. The variables can still be related in a non-linear way: points on a U-shaped curve can have a covariance of exactly zero.

How is covariance related to variance?

The covariance of a variable with itself is its variance: cov(X, X) = Σ(x − x̄)² ÷ (n − 1). Variances and covariances together form the covariance matrix used in statistics, finance and machine learning.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Correlation Coefficient CalculatorPearson r and Spearman rank correlation with significance and interpretation.Variance CalculatorSample and population variance and standard deviation with a step-by-step deviations table.Standard Deviation CalculatorStandard deviation, variance, mean, median, mode and quartiles.Linear Regression CalculatorLeast-squares line of best fit: slope, intercept, r, r², predictions and a scatter plot.Weighted Average CalculatorCalculate a weighted mean from values and weights, step by step.Average CalculatorMean, weighted average, median, sum, min and max of any list.A/B Test Significance CalculatorCheck if your A/B test result is statistically significant.Z-Score CalculatorZ-score from a value, mean and SD, plus percentile and p-value; or the value from z.Probability CalculatorFind and, or, not, conditional and at-least-once probabilities from P(A) and P(B).Permutation and Combination CalculatorCalculate nPr and nCr, with or without repetition, as exact big numbers.Mean Median Mode CalculatorFind the mean, median, mode, range, min, max, sum and count of a list of numbers.Confidence Interval CalculatorConfidence interval and margin of error for a mean or a proportion, with steps.Sample Size CalculatorHow many survey responses you need for a given confidence level and margin of error.Percentile CalculatorValue at any percentile, percentile rank of a score, quartiles, IQR and outliers.Average Order Value CalculatorAverage order value from revenue and orders, plus the revenue impact of raising AOV.Binomial Distribution CalculatorBinomial probabilities P(X = k), at most, at least or between, with mean, variance and chart.Normal Distribution CalculatorNormal probabilities P(X < x), between two values and inverse percentiles, on a shaded bell curve.Poisson Distribution CalculatorPoisson probabilities for a rate λ: exactly k, at most, at least or between, with a chart.T-Test CalculatorOne-sample, two-sample (Welch/pooled) and paired t-tests with p-value and CI.Chi-Square CalculatorChi-square goodness-of-fit and independence tests with p-value and expected counts.P-Value CalculatorOne- or two-tailed p-values from z, t, chi-square or F statistics, with critical values.Five Number Summary CalculatorMin, Q1, median, Q3, max, IQR and fences of a data set, with a box plot.Outlier CalculatorFind outliers with 1.5×/3× IQR fences, z-scores or modified z-scores; get the cleaned data.Geometric Mean CalculatorGeometric, harmonic, arithmetic and quadratic means compared, or average growth from % changes.Expected Value CalculatorExpected value, variance and standard deviation from outcomes and their probabilities.One-Way ANOVA CalculatorOne-way ANOVA for 2-10 groups: SS, df, MS, F statistic, p-value, effect size and full table.Bayes Theorem CalculatorPosterior P(A|B) from P(A), P(B|A) and P(B|not A), with a probability tree and table.Box Plot MakerPaste data to draw box-and-whisker plots with quartiles, IQR and outliers. Download PNG or SVG.Coefficient of Variation CalculatorCV % from a dataset (sample or population) with mean, SD and a two-dataset comparison.Critical Value CalculatorCritical values of z, t, chi-square and F for any alpha, tails and degrees of freedom.Dice Probability CalculatorOdds of rolling a sum (exactly, at least, at most) with any dice, plus the full distribution.Effect Size Calculator (Cohen's d)Cohen's d, Hedges' g and Glass's delta from two means, SDs and sample sizes, with CI.Frequency Table GeneratorMake a frequency, relative and cumulative frequency table from numbers or categories.Histogram MakerPaste numbers, choose bins and get a histogram, frequency table and PNG download.Margin of Error CalculatorSurvey margin of error from sample size, confidence and proportion, with population correction.Moving Average CalculatorSimple, exponential and weighted moving averages of a data series, with table and line chart.Odds Ratio and Relative Risk CalculatorOdds ratio, relative risk, risk difference, 95% CIs and p-values from a 2x2 table.Standard Error CalculatorStandard error of the mean from data or SD and n, plus SE of a proportion, with CIs.Descriptive Statistics CalculatorPaste data and get mean, median, mode, quartiles, SD, skewness, kurtosis and a histogram.Empirical Rule Calculator68-95-99.7 rule ranges from a mean and standard deviation, with a shaded bell curve.Z-Table (Standard Normal Table)Interactive z-table: find the area for any z-score, or the z-score for a probability.Average Rate of Change CalculatorAverage rate of change of f(x), two points or a data table over [a, b], with the secant line.Binomial Expansion CalculatorExpand (a + b)^n with the binomial theorem: every term, Pascal coefficients and any specific term.Combinations GeneratorList every k-combination of your items, with or without repetition, and copy or export them.Grouped Data CalculatorMean, median, mode, variance and standard deviation from class intervals and frequencies.Inverse Normal Distribution CalculatorinvNorm: find the x or z value for a left, right, central or two-tail area, with a shaded curve.Permutations GeneratorList all permutations of letters, words or items, with k-permutations and repeats, and export them.Statistical Power CalculatorPower or required sample size for t-tests, proportions and correlations, with a power curve.T Distribution CalculatorStudent's t probabilities and critical values for any df, with the area shaded on the curve.T-Table (Student's t Distribution)Interactive t-table: critical t-values for any df and α, p-values, and a printable full table.Z-Test CalculatorOne-sample, two-sample and proportion z-tests with z, p-value, decision and shaded curve.Shannon Entropy CalculatorEntropy of text, data or probabilities in bits, nats or hartleys with a frequency table.
See all 52 Statistics & Probability Calculators →