Scripting > Math Functions


Forward Moving Average Smoothing of time series

forwardMovingAverage(integer numberToAverageOver, 0/1 onlyValidValues, 0/1 useReduced)

 

Derive a new time series from the forward moving average of the last numberToAverageOver values of the current time series. If onlyValidValues is set to true, then if points in the averaging interval are missing values, the point in the new time series is set to missing.  If onlyValidValues is set to false and missing values are contained in the averaging interval, a smoothed point is still computed using the valid values in the interval.  If there are no valid values in the averaging interval, the point in the new time series is set to missing.

 

If useReduced is set to true, then forward moving average points can be still be computed at the beginning of the time series even if there are less than numberToAverageOver values in the interval.If useReduced is set to false, then the first numberToAverageOver points of the new time series are set to missing.

 

Parameters:

numberToAverageOver – An integer containing the number of values to average over for computing the forward moving average.

onlyValidValues – Either Constants.TRUE, or Constants.FALSE, specifying whether all values in the averaging interval must be valid for the computed point in the new time series to be valid.

useReduced – Either Constants.TRUE, or Constants.FALSE, specifying whether  to allow points at the beginning and end of the resultant time series to be computed from a reduced ( less than numberToAverageOver ) set of points.

Example: tsAveraged = tsData.forwardMovingAverage(4,Constants.TRUE,Constants.TRUE)

Returns: A new time series computed from the forward moving average of current time series.

Generated Exceptions:  Throws a hec.hecmath.HecMathException if the numberToAverageOver is less than 2.