Versions:

# corr()

ToolkitTimescaleDB Toolkit functions are available under Timescale Community Edition. They are automatically included with Timescale Cloud. Click to learn more.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.

corr(summary CounterSummary) RETURNS DOUBLE PRECISION

For more information about counter aggregation functions, see the hyperfunctions documentation.

Name | Type | Description |
---|---|---|

summary | CounterSummary | The input CounterSummary from a counter_agg call |

Name | Type | Description |
---|---|---|

corr | DOUBLE PRECISION | The correlation coefficient computed from the least squares fit of the adjusted counter values input to the CounterSummary |

SELECTid,bucket,corr(summary)FROM (SELECTid,time_bucket('15 min'::interval, ts) AS bucket,counter_agg(ts, val) AS summaryFROM fooGROUP BY id, time_bucket('15 min'::interval, ts)) t

Found an issue on this page?

Report an issue!Keywords