pearsonr() function

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)

This documentation is open source. See a typo? Please, open an issue.


Need help getting up and running? Get Support