stateIterate#

swordfish.function.stateIterate()#

Supposing the iteration is based only on the previous result, for the k-th (k ∈ N+) record, the calculation logic is (where the column “factor” holds the results):

  • k < initialWindow: factor[k] = initial[k]

  • k >= initialWindow:factor[k] = combineCoeff[0] * X[k] + combineCoeff[1] * iterateFunc(factor)[k-1]

If iterateFunc is a window function, the iteration is based on multiple previous results.

Parameters:
  • X (Constant) – A a vector. It can be a column from the engine’s input table, or the result of a vectorized function with the column as its input argument.

  • initial (Constant) – A vector used to fill the first initialWindow values in the corresponding result column of the engine’s output table. It can be a column from the engine’s input table, or the result of a vectorized function with the column as its input argument.

  • initialWindow (Constant) – A positive integer determining the initial window size [0, initialWindow).

  • iterateFunc (Constant) –

    Tthe function for iteration, whose only parameter is the column from the output table. Currently, only the following functions are supported (use partial application to specify functions with multiple parameters): - Moving functions: tmove, tmavg, tmmax, tmmin, tmsum, mavg, mmax, mmin, mcount, msum

    • Cumulative window functions: cumlastNot, cumfirstNot

    • Order-sensitive functions: ffill, move

    Note

    • As the iterations are performed based on the historical data, the output for the current record is calculated based on the historical results in the output table and X.

    • When calculating with time-based moving windows, windows are determined by the current timestamp T, and the interval is (T - window, T).

  • combineCoeff (Constant) – A ector of length 2. The elements indicate the correlation coefficients between the result of interateFunc and X.