Class RegrAccumulator

java.lang.Object
dev.frostlake.functions.aggregate.RegrAccumulator
All Implemented Interfaces:
AggregateFunction.Accumulator

public class RegrAccumulator extends Object implements AggregateFunction.Accumulator
Shared accumulator for the REGR_* linear-regression family. All nine functions are derived from the same running sums over the non-null (y, x) pairs — note Snowflake's argument order REGR_xxx(y, x), with the dependent variable y first and the independent variable x second. getResult() returns the member selected by RegrKind.

With n pairs and centered sums Sxx = Σx² − (Σx)²/n, Syy, Sxy: COUNT = n; AVGX = Σx/n; AVGY = Σy/n; SXX = Sxx; SYY = Syy; SXY = Sxy; SLOPE = Sxy/Sxx; INTERCEPT = AVGY − SLOPE·AVGX; R2 = NULL if Sxx=0, else 1 if Syy=0, else Sxy²/(Sxx·Syy) (= CORR²).

  • Constructor Details

    • RegrAccumulator

      public RegrAccumulator(RegrKind kind)
  • Method Details