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
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
stream1 = from(bucket:"example-bucket")
|> range(start:-15m)
|> filter(fn: (r) =>
r._measurement == "mem" and
r._field == "used"
)
stream2 = from(bucket:"example-bucket")
|> range(start:-15m)
|> filter(fn: (r) => r
._measurement == "mem" and
r._field == "available"
)
pearsonr(x: stream1, y: stream2, on: ["_time"])
Function definition
pearsonr = (x,y,on) =>
cov(x:x, y:y, on:on, pearsonr:true)