AI Glossary / Statistics and probability / Intermediate

Covariance

Definition

Covariance measures how two variables vary together relative to their respective means. Positive covariance indicates that same-direction deviations tend to dominate; negative covariance indicates that opposite-direction deviations dominate. Its magnitude depends on measurement units. Covariance describes association and does not, by itself, establish causation or independence.

What it means

Imagine recording workload and completion time for several days. When workload is above its average, completion time may also tend to be above its average. Their covariance can summarize that tendency.

It combines paired deviations rather than comparing the two averages. Two variables can have very different averages and still move closely together. Conversely, similar averages do not imply any relationship.

Covariance is a building block for correlation, multivariate modeling, uncertainty propagation, and many AI methods. Its scale dependence makes it less convenient than correlation for comparing association strengths across variables measured in different units, but that same unit information is useful when calculating the variance of combined quantities.

How it works

For random variables with suitable finite moments, Cov(X,Y) = E[(X - E[X])(Y - E[Y])]. Expanding the product gives the equivalent expression E[XY] - E[X]E[Y].

For n paired observations, the usual sample covariance is the sum of (x_i - x_bar)(y_i - y_bar), divided by n - 1. Under independent identically distributed sampling with finite second moments, this is an unbiased estimator of population covariance. A descriptive calculation treating the observed values as an entire finite population instead divides by n.

Adding a constant to either variable leaves covariance unchanged. Multiplying X by a and Y by b multiplies their covariance by ab. The covariance of a variable with itself is its variance. These properties explain both its usefulness and its sensitivity to scale.

Three practical examples

  • An AI operations team studies whether daily request volume and response latency vary together, while checking whether time trends drive the relationship.
  • A forecasting team estimates whether errors from two models tend to occur in the same direction before combining their forecasts.
  • A sensor system uses covariance to represent how uncertainty in two measurements is related, rather than assuming every measurement error is independent.

Think of it this way

Think of two dancers moving around their own starting positions. Covariance asks whether their movements tend to point in the same or opposite directions. Measuring one dancer's movement in centimeters instead of meters changes the numerical score without changing the choreography.

Worked example

Consider an original dataset of three paired observations: (1,2), (2,1), and (3,6). The X mean is 2, and the Y mean is 3.

The centered pairs are (-1,-1), (0,-2), and (1,3). Their products are 1, 0, and 3, summing to 4. The sample covariance is 4/(3 - 1) = 2.

The sample variance of X is (1 + 0 + 1)/2 = 1. The sample variance of Y is (1 + 4 + 9)/2 = 7. Consequently, the sample correlation is 2/sqrt(1 × 7), approximately 0.756.

If Y is converted to a unit one hundred times smaller, its numerical values become 200, 100, and 600. Covariance becomes 200, while correlation remains approximately 0.756. The association has not become stronger merely because the covariance number increased.

If the three original pairs are treated as a complete equally weighted finite population, their covariance is instead 4/3. State the convention rather than presenting these two denominators as an arithmetic disagreement. Neither small calculation supports a causal conclusion.

Illustrative case study

Fictional case: Beacon Analytics combines two forecasts of support demand. Each forecast has moderate error, and managers initially assume averaging them will halve the problem.

The analyst examines paired errors on the same evaluation periods. Both models tend to underpredict during unexpected launches, producing positive error covariance. Their shared misses limit the improvement available from averaging.

The team investigates a model with different information and compares combinations on a separate evaluation period. It also checks bias and overall accuracy: low covariance alone does not make a poor forecast useful. The resulting decision is based on the complete error behavior, rather than covariance as a standalone ranking.

Common misconceptions and mistakes

  • Zero covariance does not generally imply independence. For a symmetric X and Y = X squared, covariance can be zero despite a deterministic relationship.
  • Independence implies zero covariance when the required moments exist; the reverse needs additional assumptions.
  • Covariance is not restricted to the interval from -1 to 1.
  • A positive value does not mean every observed pair moves together.
  • Trends, outliers, aggregation, or mismatched timestamps can distort interpretation.
  • Two arrays must contain meaningfully paired observations; sorting each independently changes the question and usually destroys the original pairing.

Business use

Covariance helps businesses reason about combined uncertainty. For example, Var(X + Y) = Var(X) + Var(Y) + 2Cov(X,Y). Ignoring positive covariance understates variability in the sum, while ignoring negative covariance overstates it.

Before using an estimate, record the measurement units, observation period, missing-data handling, and sampling assumptions. In changing systems, historical covariance may not represent future conditions. A single estimate should not conceal differences across workloads or regimes.

For machine-learning features, use covariance alongside visual inspection and domain knowledge. It detects a particular kind of co-movement; nonlinear dependence or important rare events can remain hidden in a near-zero summary.

People also ask

How does covariance differ from correlation?

Correlation standardizes covariance by the product of standard deviations, when both are positive and finite.

Can covariance be negative?

Yes; opposite-direction centered movements can dominate.

Is a covariance of zero proof that variables are unrelated?

No. It rules out this particular second-moment association, not every form of dependence.

Check your understanding

Answer: 1.

What happens when one variable is multiplied by ten?

Answer: Its covariance with the other is multiplied by ten. 2.

Does adding ten to every observation change covariance?

Answer: No, because deviations from the mean remain the same. 3.

Why does the worked example distinguish n and n - 1?

Answer: They correspond to different descriptive and estimation conventions.

Related terms

  • Variance
  • Correlation
  • Covariance matrix
  • Independence
  • linear association
  • forecast combination
  • uncertainty propagation

Learn next

Practice calculating centered products and comparing covariance with correlation. Then study covariance matrices and the variance of linear combinations. Use examples with nonlinear relationships to understand why zero covariance is weaker than independence.

  • Correlation
  • Variance
  • Independence

More in Statistics and probability

  • Count data - Count data record how many events, objects, or observations occur within a defined unit, category, period, or amount of exposure.
  • Counter­balancing - Counterbalancing is the planned distribution of condition orders across participants or trials to reduce confounding between experimental conditions and...
  • Counternull - A counternull is a nonnull effect value that has the same evidential standing as a specified null value under a stated statistical procedure, commonly...
  • Covariance function - A covariance function specifies the covariance between a random process's values at two inputs.
  • Cox model - The Cox model usually means Cox proportional hazards regression, a method relating predictors to the time until an event while accommodating appropriate...
  • Cramér's phi ( F c ) - Cramér's phi, commonly written phi_c and more widely known as Cramér's V, measures association between two categorical variables in a contingency table.

Sources

Marco Taboga, Covariance, Lectures on probability theory and mathematical statistics: https://www.statlect.com/fundamentals-of-probability/covariance

David Howell, Statistical Methods for Psychology glossary, Covariance: https://www.uvm.edu/~statdhtx/methods8/Glossary/Glossary.html

The author educational accounts were read. The paired dataset, unit-conversion calculation, and fictional forecast case are original teaching material.

Previous: Coupling flow Next: Covariance function

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer