pearsonr() function

Warning! This page documents an earlier version of Flux, which is no longer actively developed. Flux v0.36 is the most recent stable version of Flux.

The pearsonr() function computes the Pearson R correlation coefficient between two streams by first joining the streams, then performing the covariance operation normalized to compute R.

Function type: Aggregate
Output data type: Float

pearsonr(x: stream1, y: stream2, on: ["_time", "_field"])

Parameters

x

First input stream used in the operation.

Data type: Object

y

Second input stream used in the operation.

Data type: Object

on

The list of columns on which to join.

Data type: Array of strings

Examples

stream1 = from(bucket:"telegraf/autogen")
  |> range(start:-15m)
  |> filter(fn: (r) =>
    r._measurement == "mem" and
    r._field == "used"
  )

stream2 = from(bucket:"telegraf/autogen")
  |> range(start:-15m)
  |> filter(fn: (r) => r
    ._measurement == "mem" and
    r._field == "available"
  )

pearsonr(x: stream1, y: stream2, on: ["_time", "_field"])

Function definition

pearsonr = (x,y,on) =>
  cov(x:x, y:y, on:on, pearsonr:true)