differenceSeasonal function

List<double> differenceSeasonal(
  1. List<double> x,
  2. int s,
  3. int D
)

Seasonal differencing: apply D times with period s: x_t - x_{t-s}

Implementation

List<double> differenceSeasonal(List<double> x, int s, int D) {
  if (D == 0) return List<double>.from(x);
  var y = List<double>.from(x);
  for (int k=0; k<D; k++) {
    final ny = <double>[];
    for (int t=s; t<y.length; t++) ny.add(y[t] - y[t - s]);
    y = ny;
  }
  return y;
}