Analog vs digital version of Butterworth filter in SciPy

1.3k views Asked by At

I have a question about the analog and digital versions of the Butterworth filter in SciPy. I tried two things to get a digital Butterworth filter:

  • Getting an analog filter by scipy.signal.butter with analog=True, and then using scipy.signal.bilinear to transform it into a digital filter.
  • Directly getting from the function scipy.signal.butter with analog=False.

I got different results from the two methods. Should I expect same result from these two approaches? My code:

from scipy import signal

b1, a1 = signal.butter(1, 1, 'high', analog=True)
print("analog filter: ", [b1, a1])

fs = 100

b2, a2 = signal.bilinear(b1, a1, fs)
print("digital filter from bilinear transformation of analog filter: ", [b2, a2])


b, a = signal.butter(1, 1*2/fs, 'high', analog=False)
print("digital filter: ", [b, a])

Output:

analog filter:  [array([1., 0.]), array([1., 1.])]
digital filter from bilinear transformation of analog filter:  [array([ 0.99502488, -0.99502488]), array([ 1.        , -0.99004975])]
digital filter:  [array([ 0.96953125, -0.96953125]), array([ 1.        , -0.93906251])]
1

There are 1 answers

3
hit On

I just get the answer to this question by reading some materials about digital filters a note about digital filter

The bilinear transformation formula between analogue filter and digital filter gives us a non-linear relationship between the analogue frequency formula and digital frequency formula as introduced in the material.

formula

Thus, if a digital filter is needed, directly design it from scipy.signal.butter is better.