mavg#

swordfish.function.mavg()#

If X is a vector, return a vector of the same length as X. If the second parameter is:

  • window: Calculate the moving averages of X in a sliding window of length window.

  • weights: A weight vector used to alculate the moving weighted averages of X in a sliding window of length weights. The order of weights corresponds one-to-one with the data in the window. The length of weights (the weight vector) must be in [0,1024]. Return NULL for the first (size(weights) - 1) elements. If weights is specified, the parameter minPeriods doesn’t take effect.

If X is a matrix/table, conduct the aforementioned calculation within each column of X. The result is a matrix with the same shape as X.

Parameters:
  • X (Constant) – A vector/matrix/table/tuple (with scalars or equal-length vectors)/dictionary.

  • window (Constant) – An integer no smaller than 2 or a scalar of DURATION type indicating the size of the sliding window. Note: The window size is capped at 102400 when m-functions are used in the streaming engines.

  • minPeriods (Constant, optional) – A positive integer indicating the minimum number of observations in a window required to be not null (otherwise the result is NULL).