Smoothing, exponential averages and digital filters
I always found the wide application of digital filters fascinating. However, I think that their versatility is not always intuitive.
Here, I want to discuss the connection between filters and a commonly used smoothing algorithm.
Let’s consider a stream of data denoted as \(x\), which is extremely noisy. We seek a method to obtain a smoothed version with fewer spikes. A common technique for this purpose is the exponential average. In this method, we assume that the current value \(x(n)\) is too noisy, and we intend to use the streaming history to adjust it:
Think of it this way: if we observe a value of 10, it doesn’t make much sense if all previous values were between 0 and 1. Perhaps a new event occurred, but it is more logical to assume that the increment wasn’t too large and it’s an error in the stream. The forgetting factor \(\alpha\) controls this change; the closer the value to 1, the less we rely on previous values of the system.
Now that we understand the logic behind this technique, let’s delve into a discussion. What does this smoothing algorithm have in common with a frequency filter? At least here, our goal is to clean the data, not select a frequency band.
Interestingly, our minds tend to assume that a clean signal implies a signal that is not changing drastically too often. I want to emphasize the idea of “not changing faster”; this means we associate low-band signals with “smooth signals.”
If the linguistic connection wasn’t clear enough, we can derive the spectrum of \(y\), by obtaining the discrete Fourier transform of \(y\):
Rearranging the items,
where \(G\) is the filter gain
To easily check what kind of filter is G, let’s examine its behavior as \(z\) approaches different values:
- Closer to 0Hz:
- And closer to the Nyquist frequency (the maximum frequency that we can represent in the stream):
Now, let’s unravel the implications when \(\alpha\) takes specific values:
-
Minimal smoothing: \(\alpha=0.9\) (\(x\) is almost copying \(y\)). In this case, the filter gain goes from 9 (0 Hz) to 0.81 (Nyquist’s frequency), that is, a 9.09% decrease. A minimal decrease for a minimal smoothing.
-
Strong smoothing: \(\alpha=0.1\). In this case, we trust less in the current stream values \(x\) so, probably, we will tend to over-smooth it. In the spectrum, that means that gain changes from 0.111 at 0Hz plumbetting to 0.091 at the max. frequency, in other words, a significant 81.81% decrease.
So, we can confirm that there an interplay between concepts: smoothing implicates low-pass filtering, even if not consciously perceived in that way.
But, as a consequence, an intriguing question emerges: while “low-pass” is inherently associated with “smoothness” and “high-pass” with “noise”, does a subtle conceptual association extend to “band-pass” processes? At which point, we stop thinking that something is “noisy” or “smooth”?