Docs

v2.0

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)

Bug Reports and Feedback

Thank you for being willing to help test InfluxDB v2.0 alpha! Feedback and bug reports are welcome and encouraged both for InfluxDB and this documentation.

Submit feedback in the InfluxData Community