Table of Contents

Class MovingAvg

Namespace
TimeSeriesAnalysis
Assembly
TimeSeriesAnalysis.dll

Moving-average low-pass filter

This filter is causal, meaning that for calculating the filtered value at time k it does not use future values such as k+1, this is at the expense of introducing a time-shift/phase-shift.

This is a finite-impulse-response type filter.

An alterative to this filter is LowPass, which is infinite-impulse-response, and also requires less working memory(this filter needs to hold a buffer equal to bufferSize, but LowPass only needs to keep its last value in memory). LowPass will have less phase-shift/time-shift, because it places most weight on the last datapoint, whereas this filter will weight all data points in its buffer equally and thus responds sluggish.

The advantage of this filter is that it allows you to control precisely how many past values are weighted.

LowPass HighPass BandPass
public class MovingAvg
Inheritance
MovingAvg
Inherited Members

Constructors

MovingAvg(int)

Constructor

public MovingAvg(int bufferSize)

Parameters

bufferSize int

the number of samples to average, which determines the size of the buffer to create

Methods

Filter(double)

Add value to the moving-average filter.

public double Filter(double signal)

Parameters

signal double

the scalar value to be added

Returns

double

the output of the filter, given the new value

Filter(double[])

Run filter over a vector of values

public double[] Filter(double[] signal)

Parameters

signal double[]

vector of values to be filtered

Returns

double[]

the moving-average filtered version of values