An IIR (Infinite Impulse Response) filter is a type of digital filter that uses feedback, meaning its output depends on both current and past input values and past output values. It can have an infinite duration response to an impulse.
Click to reveal answer
beginner
What does the butter function in scipy.signal do?
The butter function designs a Butterworth IIR filter, which has a smooth frequency response with no ripples in the passband or stopband. It returns filter coefficients for the desired filter order and cutoff frequency.
Click to reveal answer
intermediate
How does the cheby1 function differ from butter in scipy.signal?
The cheby1 function designs a Chebyshev Type I IIR filter, which allows ripples in the passband but has a steeper roll-off than Butterworth filters. It requires specifying the ripple amount in decibels.
Click to reveal answer
beginner
What parameters are needed to design a Butterworth lowpass filter using scipy.signal.butter?
You need to specify the filter order (an integer) and the normalized cutoff frequency (between 0 and 1, where 1 corresponds to the Nyquist frequency). You can also specify the filter type (e.g., 'low', 'high').
Click to reveal answer
intermediate
Why might you choose a Chebyshev Type I filter over a Butterworth filter?
You might choose a Chebyshev Type I filter if you want a sharper cutoff between passband and stopband and can tolerate some ripples in the passband. This can make the filter more efficient for certain applications.
Click to reveal answer
Which of the following is true about Butterworth filters?
AThey have ripples in the stopband only.
BThey have a flat passband with no ripples.
CThey have ripples in the passband only.
DThey have ripples in both passband and stopband.
✗ Incorrect
Butterworth filters are designed to have a flat frequency response in the passband with no ripples.
What parameter does the cheby1 function require that butter does not?
APassband ripple in decibels
BCutoff frequency
CFilter order
DSampling rate
✗ Incorrect
Chebyshev Type I filters require specifying the passband ripple in decibels, which controls the allowed variation in the passband.
In scipy.signal, what does the cutoff frequency parameter represent?
ANormalized frequency relative to Nyquist frequency
BFrequency in Hz
CSampling rate
DFilter order
✗ Incorrect
The cutoff frequency is normalized between 0 and 1, where 1 corresponds to the Nyquist frequency (half the sampling rate).
Which filter type generally has a steeper roll-off?
AButterworth
BMoving average
CNone of the above
DChebyshev Type I
✗ Incorrect
Chebyshev Type I filters have a steeper roll-off than Butterworth filters but allow ripples in the passband.
What does the filter order control in IIR filters?
AThe number of input samples
BThe filter's delay
CThe steepness of the filter's frequency response
DThe sampling rate
✗ Incorrect
Higher filter order means a steeper transition between passband and stopband.
Explain how to design a Butterworth lowpass filter using scipy.signal and what parameters you need.
Think about the inputs to the butter function and what they control.
You got /4 concepts.
Describe the main difference between Butterworth and Chebyshev Type I filters and when you might choose each.
Consider the trade-off between smoothness and sharpness in frequency response.
You got /3 concepts.
Practice
(1/5)
1. What is the main difference between a Butterworth and a Chebyshev IIR filter in scipy.signal?
easy
A. Butterworth filters are FIR, Chebyshev filters are IIR.
B. Butterworth filters have ripples, Chebyshev filters have a smooth response.
C. Butterworth filters are only for high-pass, Chebyshev only for low-pass.
D. Butterworth filters have a smooth frequency response, Chebyshev filters have ripples in the passband.
Assuming filter types are limited to passband types
2. Which of the following is the correct way to design a 4th order Butterworth lowpass filter with cutoff frequency 0.3 (normalized) using scipy.signal.butter?
easy
A. b, a = butter(0.3, 4, btype='low')
B. b, a = butter(4, 0.3, btype='low')
C. b, a = butter(4, 0.3, type='lowpass')
D. b, a = butter(order=4, cutoff=0.3, kind='low')
Solution
Step 1: Recall butter function signature
The function signature is butter(N, Wn, btype='low', analog=False, output='ba'), where N is order and Wn is cutoff frequency.
Step 2: Check correct parameter usage
b, a = butter(4, 0.3, btype='low') uses butter(4, 0.3, btype='low'), which matches the signature correctly.
Final Answer:
b, a = butter(4, 0.3, btype='low') -> Option B
Quick Check:
Order first, cutoff second, btype='low' = A [OK]
Hint: Order first, cutoff second, btype='low' in butter() [OK]
Common Mistakes:
Swapping order and cutoff parameters
Using wrong keyword names like 'type' or 'kind'
Passing cutoff frequency as first argument
3. What will be the output shape of the coefficients when running this code?
from scipy.signal import cheby1
b, a = cheby1(3, 1, 0.4, btype='high')
medium
A. (3,), (3,)
B. (3, 3), (3, 3)
C. (4,), (4,)
D. (2,), (2,)
Solution
Step 1: Understand cheby1 output
The function returns numerator (b) and denominator (a) coefficients arrays each of length N+1, where N is filter order.
Step 2: Calculate length for order 3
For order 3, length is 3+1 = 4, so both b and a have shape (4,).
Final Answer:
(4,), (4,) -> Option C
Quick Check:
Length = order + 1 = 4 [OK]
Hint: Coefficients length = order + 1 [OK]
Common Mistakes:
Assuming length equals order
Expecting 2D arrays instead of 1D
Confusing numerator and denominator shapes
4. Identify the error in this code snippet for designing a Chebyshev type I filter:
from scipy.signal import cheby1
b, a = cheby1(5, 0.5, 0.2, btype='bandpass')
medium
A. The cutoff frequency should be a list or tuple for bandpass, not a single float.
B. The ripple parameter is missing and required.
C. The order parameter should be a float, not integer.
D. The btype 'bandpass' is not supported by cheby1.
Solution
Step 1: Check bandpass cutoff frequency format
For bandpass filters, cutoff frequency must be a sequence (list or tuple) of two frequencies, not a single float.
Step 2: Verify other parameters
Order as integer and ripple (second parameter) are correctly provided; btype 'bandpass' is valid.
Final Answer:
The cutoff frequency should be a list or tuple for bandpass, not a single float. -> Option A
Quick Check:
Bandpass cutoff needs two frequencies = C [OK]
Hint: Bandpass cutoff must be two frequencies in a list/tuple [OK]
Common Mistakes:
Passing single float for bandpass cutoff
Confusing ripple parameter position
Using unsupported btype values
5. You want to design a Chebyshev type I lowpass filter with order 6, 0.5 dB ripple, and cutoff frequency 0.25. Which code snippet correctly creates the filter and applies it to a signal x using scipy.signal.lfilter?
hard
A. from scipy.signal import cheby1, lfilter
b, a = cheby1(6, 0.5, 0.25, btype='low')
y = lfilter(b, a, x)
B. from scipy.signal import cheby1, lfilter
b, a = cheby1(6, 0.5, 0.25, btype='high')
y = lfilter(a, b, x)
C. from scipy.signal import butter, lfilter
b, a = butter(6, 0.25, btype='low')
y = lfilter(b, a, x)
D. from scipy.signal import cheby1, lfilter
b, a = cheby1(0.5, 6, 0.25, btype='low')
y = lfilter(b, a, x)
Solution
Step 1: Verify cheby1 parameters order
Order is first parameter (6), ripple second (0.5), cutoff third (0.25), and btype='low' for lowpass.
Step 2: Check lfilter usage
lfilter takes numerator coefficients (b), denominator coefficients (a), and signal (x) in that order.
Final Answer:
from scipy.signal import cheby1, lfilter
b, a = cheby1(6, 0.5, 0.25, btype='low')
y = lfilter(b, a, x) -> Option A
Quick Check:
Correct order and lfilter usage = A [OK]
Hint: Order, ripple, cutoff in cheby1; lfilter(b, a, x) [OK]
Common Mistakes:
Swapping order and ripple parameters
Using butter instead of cheby1
Swapping b and a in lfilter
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.