Berserk Docs
Aggregate FunctionsStatistical

covariance

Calculates the sample covariance of two numeric expressions, dividing the co-moment by `n - 1`.

Rows where either value is null are ignored; fewer than two such rows give null.

Syntax

covariance(x, y)

Parameters

Prop

Type

Returns: real

Examples

Example 1 — Sample covariance of two columns

datatable(x:real, y:real)[
  1.0, 14.0,
  2.0, 10.0,
  3.0, 17.0,
  4.0, 20.0,
  5.0, 50.0
]
| summarize covariance(x, y)
covariance_x_y (real)
20.5

On this page