cov() function

The cov() function computes the covariance between two streams by first joining the streams, then performing the covariance operation.

Function type: Transformation
Output data type: Float

cov(x: table1, y: table2, on: ["_time", "_field"], pearsonr: false)



One input stream used to calculate the covariance.

Data type: Record


The other input table used to calculate the covariance.

Data type: Record


The list of columns on which to join.

Data type: Array of strings


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

Data type: Boolean


table1 = from(bucket: "example-bucket")
  |> range(start: -15m)
  |> filter(fn: (r) =>
    r._measurement == "measurement_1"

table2 = from(bucket: "example-bucket")
  |> range(start: -15m)
  |> filter(fn: (r) =>
    r._measurement == "measurement_2"

cov(x: table1, y: table2, on: ["_time", "_field"])

Function definition

cov = (x,y,on,pearsonr=false) =>
  join( tables:{x:x, y:y}, on:on )
    |> covariance(pearsonr:pearsonr, columns:["_value_x","_value_y"])

Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: