FirebirdSQL logo

CORR()

Correlation coefficient

Result type

DOUBLE PRECISION

Syntax
CORR ( <expr1>, <expr2> )
Table 1. CORR Function Parameters
Parameter Description

exprN

Numeric expression.It may contain a table column, a constant, a variable, an expression, a non-aggregate function or a UDF.Aggregate functions are not allowed as expressions.

The CORR function return the correlation coefficient for a pair of numerical expressions.

The function CORR(<expr1>, <expr2>) is equivalent to

COVAR_POP(<expr1>, <expr2>) / (STDDEV_POP(<expr2>) * STDDEV_POP(<expr1>))

This is also known as the Pearson correlation coefficient.

In a statistical sense, correlation is the degree to which a pair of variables are linearly related.A linear relation between variables means that the value of one variable can to a certain extent predict the value of the other.The correlation coefficient represents the degree of correlation as a number ranging from -1 (high inverse correlation) to 1 (high correlation).A value of 0 corresponds to no correlation.

If the group or window is empty, or contains only NULL values, the result will be NULL.

COVAR_POP()

Population covariance

Result type

DOUBLE PRECISION

Syntax
COVAR_POP ( <expr1>, <expr2> )
Table 1. COVAR_POP Function Parameters
Parameter Description

exprN

Numeric expression.It may contain a table column, a constant, a variable, an expression, a non-aggregate function or a UDF.Aggregate functions are not allowed as expressions.

The function COVAR_POP returns the population covariance for a pair of numerical expressions.

The function COVAR_POP(<expr1>, <expr2>) is equivalent to

(SUM(<expr1> * <expr2>) - SUM(<expr1>) * SUM(<expr2>) / COUNT(*)) / COUNT(*)

If the group or window is empty, or contains only NULL values, the result will be NULL.