Skip to main content
Computes the population covariance between two numeric expressions. If either one of expressions is NULL - that input row is ignored. Use this when analyzing an entire population rather than a sample. For covariance of sample see COVAR_SAMP.

Covariance vs Correlation

Covariance and correlation both describe how two variables change together, but they do so in different ways:
  • Covariance measures the direction of the relationship between two variables:
    • Positive covariance: variables tend to increase together.
    • Negative covariance: one increases as the other decreases.
    • Its value is unbounded and depends on the units of the variables, making it hard to interpret on its own.
  • Correlation, specifically Pearson correlation, standardizes the relationship:
    • It is the normalized version of covariance, giving a unitless measure between -1 and 1.
    • This makes it easier to compare the strength of relationships between different pairs of variables.
For information on correlation see CORR

Syntax

Parameters

Return Type

COVAR_POP returns a result of type DOUBLE PRECISION.

Examples

The playstats table contains the following data:

Rows: 5Execution time: 4.19ms

currentscore and currentlevel in the playstats table are highly correlated, producing a large covariance value:

Rows: 1Execution time: 7.65ms

currentlevel and currentspeed are not correlated, so their covariance is close to zero:

Rows: 1Execution time: 6.90ms