Skip to main content
Perform statistical analysis and linear regression on time-series data. These functions are similar to PostgreSQL statistical aggregates, but they include more features and are easier to use in continuous aggregates and window functions.

Two-step aggregation

This group of functions uses the two-step aggregation pattern. Rather than calculating the final result in one step, you first create an intermediate aggregate by using the aggregate function. Then, use any of the accessors on the intermediate aggregate to calculate a final result. You can also roll up multiple intermediate aggregates with the rollup functions. The two-step aggregation pattern has several advantages:
  1. More efficient because multiple accessors can reuse the same aggregate
  2. Easier to reason about performance, because aggregation is separate from final computation
  3. Easier to understand when calculations can be rolled up into larger intervals, especially in window functions and continuous aggregates
  4. Perform retrospective analysis even when underlying data is dropped, because the intermediate aggregate stores extra information not available in the final result
To learn more, see the blog post on two-step aggregates.

Samples

One-dimensional statistical analysis

Calculate the average, standard deviation, and skewness of daily temperature readings:

Two-dimensional regression analysis

Calculate the correlation coefficient and linear regression slope between two variables:

Rolling window calculations

Calculate a 7-day rolling average using the rolling window function:

Available functions

One-dimensional statistics

Two-dimensional statistics and regression