covariance() function

The covariance() function computes the covariance between two columns.

*Function type: Transformation
**
Output data type:* Float

  1. covariance(columns: ["column_x", "column_y"], pearsonr: false, valueDst: "_value")

Parameters

columns

A list of two columns on which to operate. Required

*Data type: Array of strings*

pearsonr

Indicates whether the result should be normalized to be the Pearson R coefficient.

*Data type: Boolean*

valueDst

The column into which the result will be placed. Defaults to "_value".

*Data type: String*

Examples

  1. from(bucket: "example-bucket")
  2. |> range(start:-5m)
  3. |> map(fn: (r) => ({r with x: r._value, y: r._value * r._value / 2}))
  4. |> covariance(columns: ["x", "y"])