covariance() (aggregation function)

Applies to: ✅Azure Data ExplorerAzure MonitorMicrosoft Sentinel

Calculates the sample covariance of two random variables expr1 and expr2.

Null values are ignored and don't factor into the calculation.

The following formula is used:

Image showing a covariance sample formula.

注释

This function is used in conjunction with the summarize operator.

语法

covariance( expr1, *expr2 )

Learn more about syntax conventions.

参数

名字 类型 必选 DESCRIPTION
expr1 real ✔️ First random variable expression.
expr2 real ✔️ Second random variable expression.

退货

Returns the covariance value of expr1 and expr2.

示例:

The example in this section shows how to use the syntax to help you get started.

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
20.5