Challenge - 5 Problems
DFT Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of a simple DFT calculation
What is the output of the following Python code that computes the DFT of a simple signal?
Signal Processing
import numpy as np x = np.array([1, 0, -1, 0]) X = np.fft.fft(x) print(np.round(X, 2))
Attempts:
2 left
💡 Hint
Recall that the DFT of a real-valued signal can have complex values representing frequency components.
✗ Incorrect
The input signal is a simple 4-point sequence alternating between 1 and -1. Its DFT has zero DC component and imaginary parts at frequencies 1 and 3, with values 0+2j and 0-2j respectively.
❓ data_output
intermediateNumber of frequency bins in DFT output
If you apply a Discrete Fourier Transform (DFT) to a signal with 16 samples, how many frequency bins will the output contain?
Attempts:
2 left
💡 Hint
The DFT output length matches the input length.
✗ Incorrect
The DFT output has the same number of frequency bins as the number of input samples, so 16 bins for 16 samples.
❓ visualization
advancedVisualizing magnitude spectrum of a signal
Which plot correctly shows the magnitude spectrum of a 1 kHz sine wave sampled at 8 kHz for 8 ms?
Signal Processing
import numpy as np import matplotlib.pyplot as plt fs = 8000 f = 1000 t = np.arange(0, 0.008, 1/fs) x = np.sin(2 * np.pi * f * t) X = np.fft.fft(x) freqs = np.fft.fftfreq(len(X), 1/fs) magnitude = np.abs(X) plt.stem(freqs[:len(freqs)//2], magnitude[:len(magnitude)//2]) plt.xlabel('Frequency (Hz)') plt.ylabel('Magnitude') plt.title('Magnitude Spectrum') plt.show()
Attempts:
2 left
💡 Hint
Remember the DFT output is symmetric for real signals, so peaks appear at the frequency and its mirror.
✗ Incorrect
The magnitude spectrum of a real sine wave sampled at 8 kHz shows a peak at 1 kHz and a symmetric peak at 7 kHz (which is fs - f).
🧠 Conceptual
advancedEffect of zero-padding on DFT resolution
What is the main effect of zero-padding a time-domain signal before computing its DFT?
Attempts:
2 left
💡 Hint
Think about what zero-padding does to the length of the input and the spacing of frequency bins.
✗ Incorrect
Zero-padding increases the number of DFT points, which interpolates the frequency spectrum and makes it smoother, but does not increase the true frequency resolution determined by the original signal length.
🔧 Debug
expertIdentify the error in manual DFT implementation
Consider this Python code attempting to compute the DFT manually. What error will it raise or what is the output?
Signal Processing
import numpy as np x = [1, 2, 3] N = len(x) X = [] for k in range(N): s = 0 for n in range(N): s += x[n] * np.exp(-2j * np.pi * k * n / N) X.append(s) print(X[3])
Attempts:
2 left
💡 Hint
Check the index used to access the list X after the loop.
✗ Incorrect
The list X has length 3 with indices 0,1,2. Accessing X[3] causes an IndexError because index 3 is out of range.
