Class MovingAvg
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 alterntive to this filter is LowPass, which is infinite-impulse-repsonse, 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.
LowPassHighPassBandPassInherited Members
Namespace: TimeSeriesAnalysis
Assembly: TimeSeriesAnalysis.dll
Syntax
public class MovingAvg
Constructors
| Edit this page View SourceMovingAvg(int)
Constructor
Declaration
public MovingAvg(int bufferSize)
Parameters
Type | Name | Description |
---|---|---|
int | bufferSize | the number of samples to average, which determines the size of the buffer to create |
Methods
| Edit this page View SourceFilter(double)
Add value to the moving-average filter.
Declaration
public double Filter(double signal)
Parameters
Type | Name | Description |
---|---|---|
double | signal | the scalar value to be added |
Returns
Type | Description |
---|---|
double | the output of the filter, given the new value |
Filter(double[])
Run filter over a vector of values
Declaration
public double[] Filter(double[] signal)
Parameters
Type | Name | Description |
---|---|---|
double[] | signal | vector of values to be filtered |
Returns
Type | Description |
---|---|
double[] | the moving-averge filtered version of |