Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Calculates the sample covariance of two random variables expr1 and expr2 in records for which predicate evaluates to true
.
Null values are ignored and don't factor into the calculation.
The following formula is used:
Note
This function is used in conjunction with the summarize operator.
Syntax
covariancepif(
expr1 ,
*expr2 ,
predicate)
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
expr1 | real |
✔️ | First random variable expression. |
expr2 | real |
✔️ | Second random variable expression. |
predicate | string |
✔️ | If predicate evaluates to true , values of expr1 and expr2 will be added to the covariance. |
Returns
Returns the covariance value of expr1 and expr2 in records for which predicate evaluates to true
.
Example
The example in this section shows how to use the syntax to help you get started.
This query creates a new variable y based on whether x is even or odd and then calculates the covariance of x and y for the subset of numbers where x is divisible by 3.
range x from 1 to 100 step 1
| extend y = iff(x % 2 == 0, x * 2, x * 3)
| summarize covariancepif(x, y, x % 3 == 0)
Output
covariancepif_x_y |
---|
2077.09090909091 |