CORR() OVER ...
All functions > WINDOW FUNCTION > CORR() OVER ...
Returns the Pearson correlation coefficient over the window frame.
Syntax
CORR(expr_y, expr_x) [FILTER (WHERE condition) | WITHIN (WHERE condition)] OVER ([PARTITION BY expr [, ...]] [ORDER BY sort_item [, ...]] [ROWS|RANGE|GROUPS frame])
Notes
- Returns a value between -1 (perfect negative) and 1 (perfect positive)
- NULL values in either expression are excluded
See also
Examples
FeatureQL
-- Pearson correlation of y = 2x over the whole frame
RETURN
f1 := ZIP(
ARRAY(1, 2, 3) AS id,
ARRAY(1.0e0, 2.0e0, 3.0e0) AS x,
ARRAY(2.0e0, 4.0e0, 6.0e0) AS y
).TRANSFORM(RETURN CORR(y, x) OVER ().ROUND(2)).UNWRAP()
;Result
| f1 ARRAY<DOUBLE> |
|---|
| [1.00, 1.00, 1.00] |