Local averaging

We are often interested in getting not a single measurement of an entire signal, but a quantity which changes in time as the signal progresses. In these operations, we want to transform the input signal x[n ] into an output y[n].

Consider a local or moving average, where we go through the signal from x[0] to x[k] calculating the average magnitude of every group of (say) four successive samples e.g.

(3.1)    y[n] = x[n ] + x[n-1] + x[n-2] + x[n-3]

(running means of 4). In a typical sequence of 4 dissimilar values, the average value normalizes somewhat over the sample-to-sample variations:

Plot of a portion of a signal and its running mean of 4

y[n] does not have the same rapid sample-to-sample variations that x[n] has, although over longer time periods (larger than 4 samples) the average value is greater where the average magnitude of x[n] is greater, and is less where the average magnitude of x[n] is less. Consequently y[n] reflects the grosser, slower-changing aspects of x[n], but not the finer, faster-changing details of x[n]. The faster, higher frequency components of x[n] are filtered out by smoothing. The function computed by equation (3.1) is a lowpass filter.

Spectrum of "sh" before and after means-of-4 filtering

An Octave script for calculating running means of 4 is given here.

Next: Filtering.