Click or drag to resize

MovingWindowFilter Class

Class implementing data filtering by replacing data points f(i) with a linear combination of the data points immediately to the left and right of f(i). The user provides the coefficients to use in the linear combination. Static class methods are provided for generating coefficients to implement a moving average filter and a Savitzky-Golay smoothing filter.
Inheritance Hierarchy

Namespace:  CenterSpace.NMath.Core
Assembly:  NMath (in NMath.dll) Version: 7.4
Syntax
[SerializableAttribute]
public class MovingWindowFilter : CorrelationFilter

The MovingWindowFilter type exposes the following members.

Constructors
  NameDescription
Public methodMovingWindowFilter
Constructs a MovingWindowFilter instance which implements a moving average. Number of points to the left and right both default to two.
Public methodMovingWindowFilter(Int32, Int32, DoubleVector)
Constructs a MovingWindowFilter instance with the specified parameters.
Top
Properties
  NameDescription
Public propertyCoefficients
Gets the filter coefficients.
Public propertyNumberLeft
Gets the number of points left for the filter window.
Public propertyNumberOfCoefficients
Gets the number of filter coefficients. Effectively the filter width.
(Inherited from CorrelationFilter.)
Public propertyNumberRight
Gets the number of points right for the filter window.
Public propertyWindowBoundaryOption
Gets / Sets the current boundary option.
Public propertyWindowWidth
Gets the width of the moving window.
Top
Methods
  NameDescription
Protected methodCorrelate
Does the correlation and takes care of internal correlation and work objects.
(Inherited from CorrelationFilter.)
Public methodStatic memberCode exampleExponentiallyWeightedMovingAverageCoefficients
Returns a vector of exponentially weighted moving average (EWMA) coefficients of length n.
Public methodFilter(DoubleVector)
Filters
data
with the PadWithZeros option.
(Overrides CorrelationFilterFilter(DoubleVector).)
Public methodFilter(DoubleVector, DoubleVector)
Filters
data
with the PadWithZeros option.
(Overrides CorrelationFilterFilter(DoubleVector, DoubleVector).)
Public methodFilter(DoubleVector, MovingWindowFilterBoundaryOption)
Applies the filter to the given data using the given boundary option. The given boundary option sets the current boundary option.
Public methodFilter(DoubleVector, MovingWindowFilterBoundaryOption, DoubleVector)
Applies the filter to the given data using the given boundary option and places the output in a given vector. The given boundary options sets the current boundary option.
Public methodStatic memberMovingAverageCoefficients
Constructs the coefficient vector that implements a moving average filter when used with the MovingWindowFilter class.
Public methodStatic memberSavitzkyGolayCoefficients
Constructs the coefficient vector that implements a Savitzky-Golay smoothing filter when used with the MovingWindowFilter class. The algorithm is also known by the terms, least-squares, or DIgital Smoothing POlynomial (DISPO). The filter coefficients, c(n) are chosen so as to approximate the underlying function in the window [i - nL, i + nR] with a polynomial, typically quadratic or quartic, and replace the point f(i) with the value of the approximating polynomial at i. The polynomial is fit using a least squares algorithm.
Public methodSetFilterParameters
Sets the parameters for this filter.
Top
Fields
  NameDescription
Protected fieldcoefficients_
Filtering coefficients for correlation operation.
(Inherited from CorrelationFilter.)
Protected fieldnumberLeft_
The number of points to the left.
Protected fieldnumberRight_
The number of points to the right.
Protected fieldwork_
Provides a working vector for correlation results.
(Inherited from CorrelationFilter.)
Top
Remarks
The filter replaces data points f(i) with a linear combination g(i) of itself and some number of neighboring points. The neighboring points are determined by by parameters nL, the number of points to the left, and nR, the number of points to the right: g(i) = sum(n = -nL, n = nR)c(n)*f(i+n) See also
SavitzkyGolayFilter
for more boundary options and Savitzky-Golay derivatives.
See Also