Challenge - 5 Problems
FFT Filtering Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of FFT and inverse FFT on a simple signal
What is the output of the following code snippet that applies FFT and then inverse FFT on a simple signal?
SciPy
import numpy as np from scipy.fft import fft, ifft signal = np.array([1, 2, 3, 4]) fft_signal = fft(signal) recovered_signal = ifft(fft_signal) print(np.round(recovered_signal.real, 2))
Attempts:
2 left
💡 Hint
FFT followed by inverse FFT should recover the original signal.
✗ Incorrect
FFT transforms the signal to frequency domain and inverse FFT brings it back. The recovered signal matches the original input.
❓ data_output
intermediate1:30remaining
Length of filtered signal after FFT-based low-pass filtering
Given a signal of length 8, after applying FFT-based low-pass filtering by zeroing out frequencies above index 3 and then inverse FFT, what is the length of the resulting filtered signal?
SciPy
import numpy as np from scipy.fft import fft, ifft signal = np.arange(8) fft_signal = fft(signal) fft_signal[4:] = 0 # zero out frequencies above index 3 filtered_signal = ifft(fft_signal) print(len(filtered_signal))
Attempts:
2 left
💡 Hint
FFT and inverse FFT do not change the length of the signal.
✗ Incorrect
The length of the signal remains the same after FFT and inverse FFT, even if some frequency components are zeroed out.
🔧 Debug
advanced2:00remaining
Identify the error in FFT-based filtering code
What error does the following code produce when trying to apply FFT-based filtering?
SciPy
import numpy as np from scipy.fft import fft, ifft signal = np.array([1, 2, 3, 4]) fft_signal = fft(signal) # Incorrect slicing to zero out high frequencies fft_signal[4:] = 0 filtered_signal = ifft(fft_signal) print(filtered_signal)
Attempts:
2 left
💡 Hint
Check the length of the FFT output and the slice used.
✗ Incorrect
The FFT output length is 4, so trying to access fft_signal[4:] causes an IndexError.
🧠 Conceptual
advanced1:30remaining
Effect of zeroing out frequency components in FFT
What is the effect on the time-domain signal when you zero out the high-frequency components in its FFT representation before applying inverse FFT?
Attempts:
2 left
💡 Hint
High frequencies correspond to rapid changes in the signal.
✗ Incorrect
Removing high-frequency components filters out rapid changes, making the signal smoother.
🚀 Application
expert2:30remaining
Identify the correct code for band-pass filtering using FFT
Which code snippet correctly applies a band-pass filter to keep only frequencies between indices 2 and 5 (inclusive) in the FFT of a signal, then recovers the filtered signal?
Attempts:
2 left
💡 Hint
Band-pass means keep frequencies in a range and zero out others.
✗ Incorrect
Option A correctly zeros frequencies outside 2 to 5 inclusive and keeps the rest, then applies inverse FFT.