covariance() function
The covariance()
function computes the covariance between two columns.
Output data type: Float
covariance(columns: ["column_x", "column_y"], pearsonr: false, valueDst: "_value")
Parameters
columns
(Required) A list of two columns on which to operate.
pearsonr
Normalized results to the Pearson R coefficient.
Default is false
.
valueDst
The column into which the result will be placed.
Defaults to "_value"
.
tables
Input data.
Default is piped-forward data (<-
).
Examples
The following example uses generate.from()
to generate sample data and show how covariance()
transforms data.
import "generate"
data = generate.from(count: 5, fn: (n) => n * n, start: 2021-01-01T00:00:00Z, stop: 2021-01-01T00:01:00Z)
|> toFloat()
|> map(fn: (r) => ({_time: r._time, x: r._value, y: r._value * r._value / 2.0}))
data
|> covariance(columns: ["x", "y"])
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, the following resources are available:
InfluxDB Cloud customers can contact InfluxData Support.