Smoothing.Moving Average Method
Applies a moving average filter to the specified signal.
Definition
Namespace: Numerics.NET.SignalProcessing
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
C#
The filtered signal.
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
public static Vector<double> MovingAverage(
Vector<double> signal,
int windowLength,
Padding padding = Padding.None,
double paddedValue = 0
)
Parameters
- signal Vector<Double>
- The signal to filter.
- windowLength Int32
- The length of the smoothing window. Must be odd.
- padding Padding (Optional)
- (Optional.) Specifies how the signal is padded for calculations near the lower and upper bounds. The default value is None.
- paddedValue Double (Optional)
- (Optional.) If padding is Constant, the value to use for padding; ignored otherwise.
Return Value
Vector<Double>The filtered signal.
Remarks
This method smooths a signal by computing the mean of a local neighbourhood of windowLength points around each data point.
The padding argument determines how calculations will be performed near the boundaries of the signal. The default value, None, indicates that the signal is not padded. Instead, only the available data points will be used to compute the first and last few smoothed values.
Exceptions
Argument | signal is null. |
Argument | windowLength is less than zero. |