SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.signalprocessing.filter
Class MovingAverage

java.lang.Object
  extended by com.numericalmethod.suanshu.signalprocessing.filter.MovingAverage
All Implemented Interfaces:
Filter

public class MovingAverage
extends java.lang.Object
implements Filter

This class applies a linear filtering to a univariate time series using 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.


Nested Class Summary
static class MovingAverage.Side
          the types of moving average filtering available
 
Field Summary
 MovingAverage.Side side
          the data window
 
Constructor Summary
MovingAverage(double[] filter)
          Create a MovingAverage filter using a symmetric window.
MovingAverage(double[] filter, MovingAverage.Side side)
          Create a MovingAverage filter.
 
Method Summary
 double[] filtering(double[] Xt)
          Get the filtered signals.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

side

public final MovingAverage.Side side
the data window

Constructor Detail

MovingAverage

public MovingAverage(double[] filter,
                     MovingAverage.Side side)
Create a MovingAverage filter.

Parameters:
filter - the filter coefficients in reverse time order
side - specify the data window to use

MovingAverage

public MovingAverage(double[] filter)
Create a MovingAverage filter using a symmetric window.

Parameters:
filter - the filter coefficients in reverse time order
Method Detail

filtering

public double[] filtering(double[] Xt)
Description copied from interface: Filter
Get the filtered signals.

Specified by:
filtering in interface Filter
Parameters:
Xt - the input signals
Returns:
the filtered signals

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.