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.

  1. corr(
  2. summary CounterSummary
  3. ) RETURNS DOUBLE PRECISION

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

Required arguments

NameTypeDescription
summaryCounterSummaryThe input CounterSummary from a counter_agg call

Returns

NameTypeDescription
corrDOUBLE PRECISIONThe correlation coefficient computed from the least squares fit of the adjusted counter values input to the CounterSummary

Sample usage

  1. SELECT
  2. id,
  3. bucket,
  4. corr(summary)
  5. FROM (
  6. SELECT
  7. id,
  8. time_bucket('15 min'::interval, ts) AS bucket,
  9. counter_agg(ts, val) AS summary
  10. FROM foo
  11. GROUP BY id, time_bucket('15 min'::interval, ts)
  12. ) t