0
0
SciPydata~20 mins

FIR filter design (firwin) in SciPy - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FIR Filter Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of FIR filter coefficients using firwin
What is the output array of FIR filter coefficients generated by the following code?
SciPy
from scipy.signal import firwin
coeffs = firwin(numtaps=5, cutoff=0.3)
print(coeffs)
A[0.0375 0.2491 0.4270 0.2491 0.0375]
B[0.1 0.2 0.4 0.2 0.1]
C[0.2 0.2 0.2 0.2 0.2]
D[0.05 0.15 0.5 0.15 0.05]
Attempts:
2 left
💡 Hint
The firwin function creates a lowpass filter with symmetric coefficients.
data_output
intermediate
1:30remaining
Length of FIR filter coefficients array
What is the length of the FIR filter coefficients array generated by this code?
SciPy
from scipy.signal import firwin
coeffs = firwin(numtaps=11, cutoff=0.5)
print(len(coeffs))
A10
B9
C12
D11
Attempts:
2 left
💡 Hint
The numtaps parameter defines the number of filter coefficients.
🔧 Debug
advanced
2:00remaining
Error raised by incorrect firwin usage
What error does this code raise?
SciPy
from scipy.signal import firwin
coeffs = firwin(numtaps=4, cutoff=[0.2, 0.5], pass_zero=False)
AValueError: numtaps must be odd for bandpass filters
BTypeError: cutoff must be a float for lowpass filters
CRuntimeWarning: Filter coefficients may be unstable
DNo error, runs successfully
Attempts:
2 left
💡 Hint
Bandpass filters require an odd number of taps.
🚀 Application
advanced
2:30remaining
Choosing cutoff frequencies for a bandstop FIR filter
You want to design a bandstop FIR filter using firwin to remove frequencies between 0.3 and 0.5 (normalized). Which cutoff parameter should you use?
A[0.0, 0.3]
B[0.3, 0.5]
C[0.0, 0.3, 0.5, 1.0]
D[0.3, 0.5, 1.0]
Attempts:
2 left
💡 Hint
For bandstop filters, cutoff is a list of two frequencies defining the stop band.
🧠 Conceptual
expert
3:00remaining
Effect of increasing numtaps on FIR filter characteristics
What is the main effect of increasing the numtaps parameter in firwin when designing an FIR filter?
AThe filter becomes unstable and may cause runtime errors
BThe filter's cutoff frequency shifts to a higher value
CThe filter's transition band becomes narrower, improving frequency selectivity
DThe filter coefficients become non-symmetric
Attempts:
2 left
💡 Hint
More taps mean more coefficients to shape the filter response.