oph_moving_avg

Description

Behaviour

It computes the moving average operation on each element of the measure array. Integer values will be automatically converted to real values. NaN values in the input array will be ignored. Available operations are:

  • Simple Moving Average (SMA), which computes the mean on the previous K elements using the following: m[i] = (e[i] + e[i-1] + ... + e[i-(k-1)])/k NOTE: the first k-1 elements will be set to NaN.
  • Exponentially Weighted Moving average (EWMA), which computes the exponential mean using the following: m[i] = (1-alfa) * m[i-1] + (alfa) * e[i], with m[0] = e[0]

Parameters

  • input measure type: Ophidia typing. Supported types are: ‘oph_double’; ‘oph_float’; ‘oph_long’; ‘oph_int’; ‘oph_short’; ‘oph_byte’.
  • output measure type: Ophidia typing. Supported types are: ‘oph_double’; ‘oph_float’; ‘oph_long’; ‘oph_int’; ‘oph_short’; ‘oph_byte’.
  • measure: input measure.
  • average parameter: it defines the K parameter for SMA (integer K >= 1) and the alfa parameter for EWMA (real 0 <= alfa <= 1). Default value for both is 1.
  • operation: moving average operation
    • OPH_SMA: simple moving average (default);
    • OPH_EWMA: exponentially weighted moving average.

Return type

Binary-array.

Examples

Compute SMA of each measure.

oph_moving_avg('OPH_DOUBLE', 'OPH_DOUBLE',measure, 2, 'OPH_SMA')

Operation type

Simple.

Arguments

Argument name Type Mandatory Values Default Min/Max-value Min/Max-times
input measure type “oph_type” “yes” “‘oph_double’|’oph_float’|’oph_int’|’oph_long’|’oph_short’|’oph_byte’”     “1” / “1”
output measure type “oph_type” “yes” “‘oph_double’|’oph_float’|’oph_int’|’oph_long’|’oph_short’|’oph_byte’”     “1” / “1”
measure “binary-array” “yes”       “1” / “1”
average parameter “double” “no”   “1”   “0” / “1”
operation “string” “no” “‘oph_sma’|’op_ewma’| ‘oph_sma’”   “0” / “1”