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: Transformation
**
Output data type:* Float

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

Parameters

x

First input stream used in the operation.

*Data type: Record*

y

Second input stream used in the operation.

*Data type: Record*

on

The list of columns on which to join.

*Data type: Array of strings*

Examples

  1. stream1 = from(bucket:"example-bucket")
  2. |> range(start:-15m)
  3. |> filter(fn: (r) =>
  4. r._measurement == "mem" and
  5. r._field == "used"
  6. )
  7. stream2 = from(bucket:"example-bucket")
  8. |> range(start:-15m)
  9. |> filter(fn: (r) => r
  10. ._measurement == "mem" and
  11. r._field == "available"
  12. )
  13. pearsonr(x: stream1, y: stream2, on: ["_time"])

Function definition

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