0
0
SciPydata~20 mins

IIR filter design (butter, cheby1) in SciPy - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
IIR Filter Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Butterworth filter coefficients
What is the output of the following code that designs a 3rd order Butterworth lowpass filter with cutoff frequency 0.4 (normalized) and prints the numerator coefficients?
SciPy
from scipy.signal import butter
b, a = butter(3, 0.4, btype='low')
print(b)
A[0.01809893 0.05429679 0.05429679 0.01809893]
B[ 0.09763107 0.29289322 0.29289322 0.09763107]
C[0.00482434 0.01447302 0.01447302 0.00482434]
D[0.25 0.25 0.25 0.25]
Attempts:
2 left
💡 Hint
Recall that butter() returns numerator and denominator coefficients of the filter.
data_output
intermediate
2:00remaining
Number of zeros in Chebyshev Type I filter numerator
After designing a 4th order Chebyshev Type I highpass filter with 1 dB ripple and cutoff frequency 0.3 (normalized), how many zeros does the numerator polynomial have?
SciPy
from scipy.signal import cheby1
b, a = cheby1(4, 1, 0.3, btype='high')
print(len(b) - 1)
A3
B4
C5
D1
Attempts:
2 left
💡 Hint
The numerator polynomial degree equals the filter order for IIR filters.
🔧 Debug
advanced
2:00remaining
Identify the error in filter design code
What error does the following code raise when trying to design a Butterworth bandpass filter with cutoff frequencies 0.2 and 0.5?
SciPy
from scipy.signal import butter
b, a = butter(3, [0.2, 0.5], btype='bandpass')
ANo error, returns filter coefficients
BTypeError: 'bandpass' is not a valid filter type
CValueError: Digital filter critical frequencies must be strictly increasing and 0 < Wn < 1
DSyntaxError: invalid syntax
Attempts:
2 left
💡 Hint
Check the valid filter types and cutoff frequency ranges for butter().
visualization
advanced
2:00remaining
Frequency response plot of Chebyshev Type I filter
Which option correctly plots the frequency response magnitude (in dB) of a 5th order Chebyshev Type I lowpass filter with 0.5 normalized cutoff and 0.5 dB ripple?
SciPy
import matplotlib.pyplot as plt
import numpy as np
from scipy.signal import cheby1, freqz
b, a = cheby1(5, 0.5, 0.5, btype='low')
w, h = freqz(b, a)
plt.plot(w / 3.1415, 20 * np.log10(abs(h)))
plt.xlabel('Normalized Frequency')
plt.ylabel('Magnitude (dB)')
plt.title('Frequency Response')
plt.grid(True)
plt.show()
APlots frequency response with x-axis from 0 to 1 and y-axis showing magnitude in dB
BPlots frequency response with x-axis in Hz (0 to 5000) and y-axis linear magnitude
CPlots phase response instead of magnitude
DRaises NameError due to missing numpy import
Attempts:
2 left
💡 Hint
Check if all required libraries are imported before plotting.
🚀 Application
expert
3:00remaining
Choosing filter type for sharp cutoff with minimal ripple
You need to design a digital IIR filter with a very sharp cutoff and minimal passband ripple for a biomedical signal sampled at 1000 Hz. Which filter design and parameters below best meet this requirement?
AUse a 6th order Chebyshev Type I lowpass filter with 0.5 dB ripple and cutoff 100 Hz
BUse a 6th order Butterworth lowpass filter with cutoff 100 Hz
CUse a 6th order Chebyshev Type II lowpass filter with 40 dB stopband attenuation and cutoff 100 Hz
DUse a 6th order Elliptic lowpass filter with 0.5 dB ripple and 40 dB stopband attenuation
Attempts:
2 left
💡 Hint
Chebyshev Type II filters have flat passband and sharp cutoff with stopband ripple.