Smoothing.MovingAverage Method

Applies a moving average filter to the specified signal.

Definition

Namespace: Extreme.Mathematics.SignalProcessing
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
C#
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

ArgumentNullException

signal is null.

ArgumentOutOfRangeException

windowLength is less than zero.

See Also