Class MovingAverage

  • All Implemented Interfaces:
    Filter

    public class MovingAverage
    extends Object
    implements Filter
    This applies a linear filter to a univariate time series using the moving average estimation.
    
     y[i] = f[1]*x[i+o] + … + f[p]*x[i+o-(p-1)]
     
    o is the offset, depending on whether only past values or both past and future values centered around lag 0 are used. When a symmetric window is used and the filter length is even, more of the filter is forward in time than backward.

    The R equivalent function is filter.

    • Constructor Detail

      • MovingAverage

        public MovingAverage​(double[] filter,
                             MovingAverage.Side side)
        Construct a moving average filter.
        Parameters:
        filter - the filter coefficients in reverse time order
        side - specify the data window to use
      • MovingAverage

        public MovingAverage​(double[] filter)
        Construct a moving average filter using a symmetric window.
        Parameters:
        filter - the filter coefficients in reverse time order
    • Method Detail

      • transform

        public double[] transform​(double[] x)
        Description copied from interface: Filter
        Transforms the input signal into the output signal.
        Specified by:
        transform in interface Filter
        Parameters:
        x - the input signal
        Returns:
        the filtered signal