corr()
The correlation coefficient of the least squares fit line of the adjusted counter value and epoch value of the time column. Given that the slope of a line for any counter value must be non-negative, this must also always be non-negative and in the range from 0.0 to 1.0. It measures how well the least squares fit the available data, where a value of 1.0 represents the strongest correlation between time and the counter increasing.
2. corr(
4. summary CounterSummary
6. ) RETURNS DOUBLE PRECISION
For more information about counter aggregation functions, see the hyperfunctions documentation.
Required arguments
| Name | Type | Description |
|---|---|---|
| summary | CounterSummary | The input CounterSummary from a counter_agg call |
Returns
| Name | Type | Description |
|---|---|---|
| corr | DOUBLE PRECISION | The correlation coefficient computed from the least squares fit of the adjusted counter values input to the CounterSummary |
Sample usage
2. SELECT
4. id,
6. bucket,
8. corr(summary)
10. FROM (
12. SELECT
14. id,
16. time_bucket('15 min'::interval, ts) AS bucket,
18. counter_agg(ts, val) AS summary
20. FROM foo
22. GROUP BY id, time_bucket('15 min'::interval, ts)
24. ) t
