Documentation

covariance() function

Flux 0.7.0+

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

Output data type: Float

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

Parameters

columns

(Required) A list of two columns on which to operate.

pearsonr

Normalized results to the Pearson R coefficient. Default is false.

valueDst

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

tables

Input data. Default is piped-forward data (<-).

Examples

The following example uses generate.from() to generate sample data and show how covariance() transforms data.

import "generate"

data = generate.from(count: 5, fn: (n) => n * n, start: 2021-01-01T00:00:00Z,stop: 2021-01-01T00:01:00Z  ) 
  |> toFloat()
  |> map(fn: (r) => ({_time: r._time, x: r._value, y: r._value * r._value / 2.0}))
 
data
  |> covariance(columns: ["x", "y"])

View input and output


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.