I am designing some Downsampling filters using the remez exchange algorithm (Matlab FDAtool). I see that some times i get a spike at the first and last coefficients. does anybody knows why is that? my intuition seems to be that this can introduce some artifacts to the signal.. What will be the consequance of multiplying the filter by a window (hamming and so on) to reduce this edge effects?
2 Answers
The "spikes" (they are quite small in magnitude, but large compared to the nearby filter taps) at the beginning and end are part of how the equiripple property is achieved. In his book "Multirate Signal Processing for Communication Systems" (a book that I recommend quite highly), fredric harris indicates that it is sometimes advantageous to eliminate the spikes because it causes the frequency response to continue to decrease after the cut-off frequency instead of staying constant. The price you pay is that the filter is no longer equiripple which appears to cause (see example below and comments by JasonR) the transition band to be not as sharp.
EDIT:
I created a low-pass filter in Octave using remez. I intentionally made the transition-band very small to get it to create a decent spike. The filter taps are plotted below.
Here is the frequency response of the filter.
As you can see, the frequency response is pretty poor due to the short transition-band, but the point is that it is an equiripple filter. Below I plot the exact same filter, only I have zeroed out the two spike taps.
Below is the frequency response of the "no spikes" version of the filter.
The frequency response shows the continued drop beyond the cutoff frequency. It also clearly shows the non-equiripple response in the pass-band. This is entirely expected. The one thing that is unexpected is that the "no spike" filter appears to be better than the "spike" filter at every point. I assume that this is because of some flaw in Octave's remez algorithm.
-
$\begingroup$ Nice answer - why are you saying the non-spike filter looks better than spike one?... $\endgroup$– SpaceyAug 6, 2012 at 2:26
-
$\begingroup$ Because the pass-band ripple is less than the spiked version, and the attenuation is greater in the stop band. The transition band is probably wider, which is why remez didn't come up with the non-spike version in the first place, but in every other respect the non-spiked version seems to be clearly better to me. $\endgroup$– Jim ClayAug 6, 2012 at 3:16
-
$\begingroup$ @JimClay I don't think it's a flaw in remez, it's just the nature of the change in the approximation. By sacrificing some localized error tolerance (probably around the transition), you gain much better approximation over the entire range (cf. "Myth 3" in eprints.maths.ox.ac.uk/1352). $\endgroup$– datageist ♦Aug 6, 2012 at 3:30
-
$\begingroup$ @JimClay: What parameters did you use to design the above filter? The Octave source code would do; I've not noticed this particular phenomenon before, but then again, I've never really looked for it either. $\endgroup$– Jason RAug 7, 2012 at 1:04
-
1$\begingroup$ @JimClay: Thanks. I duplicated the example in MATLAB. If you plot the two filter responses on top of one another, you'll see that there are regions where the equiripple filter is better, namely in the region just around the specified stopband frequency of 0.51. The modified filter has a slightly longer transition region, such that it may not meet the stopband specification any longer. Nice trick, though, as you do end up with much less passband ripple at a relatively small cost in cutoff sharpness. $\endgroup$– Jason RAug 7, 2012 at 14:02
This was an interesting thread.
It's interesting to note that if you use an FIR filter, having the spikes at the beginning and end of its impulse response, to filter an audio signal, there will be a faint (low-level) 'click' at the beginning and end of your filtered audio signal. Some people can hear, and are bothered by, those clicks.