content/flux/v0/stdlib/universe/cov.md
cov() computes the covariance between two streams of tables.
(on: [string], x: A, y: B, ?pearsonr: bool) => stream[C] where C: Record
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
({{< req >}}) First input stream.
({{< req >}}) Second input stream.
({{< req >}}) List of columns to join on.
Normalize results to the Pearson R coefficient. Default is false.
import "generate"
stream1 =
generate.from(
count: 5,
fn: (n) => n * n,
start: 2021-01-01T00:00:00Z,
stop: 2021-01-01T00:01:00Z,
)
|> toFloat()
stream2 =
generate.from(
count: 5,
fn: (n) => n * n * n / 2,
start: 2021-01-01T00:00:00Z,
stop: 2021-01-01T00:01:00Z,
)
|> toFloat()
cov(x: stream1, y: stream2, on: ["_time"])
{{< expand-wrapper >}} {{% expand "View example output" %}}
| _value |
|---|
| 87.75 |
{{% /expand %}} {{< /expand-wrapper >}}