1
$\begingroup$

I have data from an experiment and apply a lowpass filter (digital Butterworth filter, in Matlab).

My question ist what happens if I apply the same filter e. g. 2 times on the data?

What is changing? Is it like I have the double order?


The question refers to the filtfilt function in Matlab:

http://www.mathworks.de/de/help/signal/ref/filtfilt.html

The source [1] says on page 336:

In many filtering problems, we would prefer that the phase characteristics be zero or linear. For causal filters, it is impossible to have zero phase. However, for many filtering applications, it is not necessary that the impulse response of the filter be zero for n < 0 if the processing is not to be carried out in real time. One technique commonly used in discrete-time filtering when the data to be filtered are of finite duration and are stored, for example, in computer memory is to process the data forward and then backward through the same filter.

[1] Oppenheim, Alan V., Ronald W. Schafer, and John R. Buck. Discrete-Time Signal Processing. 2nd Ed. Upper Saddle River, NJ: Prentice Hall, 1999.

$\endgroup$
  • 1
    $\begingroup$ Hey. Why would you down vote this question? $\endgroup$ – Dr. Manuel Kuehner Sep 16 '14 at 20:27
2
$\begingroup$

Silly me! The Matlab help includes the answer:

  • A filter transfer function, which equals the squared magnitude of the original filter transfer function
  • A filter order that is double the order of the filter specified by filter coefficients $b_0$, $b_1$, $b_2$,... and $a_1$, $a_2$....
$\endgroup$
  • $\begingroup$ You got it, the easy way to understand this is in the frequency domain, applying the filter is an element-wise multiplication. Applying it again is just another multiplication, equivalent to multiplying by the squared impulse response. $\endgroup$ – gct Sep 16 '14 at 14:53
  • $\begingroup$ @gct, i certainly do not understand a correct meaning to what you wrote. it is not equivalent to multiplying by the squared impulse response. more like convolving with the impulse response twice. but in the filtfilt case, one of the impulse responses are reversed in time. $\endgroup$ – robert bristow-johnson Sep 16 '14 at 17:24
  • $\begingroup$ Convolution becomes multiplication in the frequency domain, so when you convolve with the same thing twice in the time domain, it becomes equivalent to multiplying by its squared response in the frequency domain. $\endgroup$ – gct Sep 16 '14 at 21:35
  • $\begingroup$ and "multiplying by the squared impulse response" (which would be in the time domain) is not the same as convolving twice by the impulse response. nor is it the same as multiplying by the squared frequency response in the frequency domain. that's why i couldn't grok your comment. $\endgroup$ – robert bristow-johnson Sep 18 '14 at 21:39
2
$\begingroup$

How about answer your question in an ultimate way? What will happens to if you apply a low pass filter infinite times or practically a large number of times? I believe it is more meaningful for you to understand this one.

I want to first emphasize the fact that apply a filter $F$ to $d$ for $k$ times, is equivalent to apply a filter $F'$ to $d$ for once, if we have $$F' = \underbrace{F*F*\cdots*F}_{k \,{\rm times}} $$.

The answer to the 'ultimate' version of your question is that: no matter where you start with your lowpass filter, say $F=[f_0,f_1,\cdots,f_n]$, with $\sum_{i=0}^{n} f_i = 1$ and $f_i \geq 0$, you will end up to apply a Gaussian filter $G$ when you apply filter $F$ to some discrete signal $d=[d_0,d_1,\cdots,d_m]$ for $k\rightarrow\infty$ times.

Note: this conclusion does not rely on 1) what is the signal to be processed $d$, 2) which $F$ you use, as along as it is lowpass.

Here is some ipython code, you might play with.

import numpy as np
# generate a random low pass filter
F = np.random.randint(0,1000,(100,1) ).astype('float').ravel();
# ensures sum to 1
F = F / F.sum();
print "sum(F) = ", F.sum();
# create copy to buffer the last version of convolving F for k times
Fk = F.copy();
Fk_list = [];
for k in range( 5 ) :
    Fk = np.convolve( Fk, F, 'full' );
    Fk = Fk / Fk.sum();
    # donot worry about this line, see comments below
    Fk = np.asarray( filter( lambda x : x > 1e-6, Fk ) );
    Fk = Fk / Fk.sum();
    Fk_list.append( Fk );
# plot results
f, axarr = pyplot.subplots( 3, 2 );
# plot data
axarr[0,0].plot( F ),
axarr[0,0].set_title( 'k = 0' );
axarr[0,1].plot( Fk_list[0] ),
axarr[0,1].set_title( 'k = 1' );
axarr[1,0].plot( Fk_list[1] ),
axarr[1,0].set_title( 'k = 2' );
axarr[1,1].plot( Fk_list[2] ),
axarr[1,1].set_title( 'k = 3' );
axarr[2,0].plot( Fk_list[3] ),
axarr[2,0].set_title( 'k = 4' );
axarr[2,1].plot( Fk_list[4] ),
axarr[2,1].set_title( 'k = 5' );
pyplot.show();
  • the line that with filter keyword is simply to discard very small components, because I want to keep you see beautiful bell shape Gaussian. Otherwise, the results are still Gassuian, but since we might include many things outside of 4 times of standard deviation, you will see something like a peak instead.

Here are the results of the above ipython code. As you can see, the more times of convolve to $F$ self, the resulting lowpass filter is more similar to a Gaussian.

convolve a random low pass filter

Now let me give you another visual demonstration by using a very different $F$, which only contains two nonzero values. Though this time you cannot see $F$ to be Gaussian like in 5 times of convolution, the long term behaviour namely, $k\rightarrow\infty$ does not change. It will be Gaussian like after a large number of self-convolution.

convolve a very sparse low pass filter

Finally, you might ask why this thing happens? Because God loves Gaussian. This conclusion is so-called the 'Central Limit Theorem' ( see details in http://en.wikipedia.org/wiki/Central_limit_theorem ). I am not gonna to explain everything for you, because I wish you could learn this on your own. But here is a hint: probability / discrete distribution, arithmetic mean, low-pass filter coefficients, linear operators, and convolution, they are all related. If you have any difficulty to understand something new, try to understand it via something you already knew with close relationships.

$\endgroup$
  • $\begingroup$ Thank you very much for this elaborate and amazing answer. $\endgroup$ – Dr. Manuel Kuehner Sep 19 '14 at 8:08
1
$\begingroup$

digital Butterworth filter, in Matlab).

My question ist what happens if I apply the same filter e. g. 2 times on the data?

What is changing? Is it like I have the double order?

Not quite. A 2nd-order Butterworth cascaded with a 2nd-order Butterworth will produce a 4th-order filter, but it will not be a 4th-order Butterworth. It will have 6 dB down at the cutoff frequency instead of 3 dB down.

To make the total frequency response Butterworth, you'd need to use different Qs for the forward and backward biquads. I'm not sure what effect it would have for them to be asymmetrical.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.