Challenge - 5 Problems
Signal Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateWhat is the output of this signal smoothing code?
Given a noisy signal, what does the following code output after applying a simple moving average filter?
Signal Processing
import numpy as np signal = np.array([1, 3, 2, 5, 8, 7, 6, 4, 3, 2]) window_size = 3 smoothed = np.convolve(signal, np.ones(window_size)/window_size, mode='valid') print(smoothed)
Attempts:
2 left
💡 Hint
Think about how a moving average smooths the signal by averaging over a sliding window.
✗ Incorrect
The np.convolve with a window of ones divided by window size computes the average of each consecutive group of 3 elements, producing a smoothed signal shorter than the original.
❓ data_output
intermediateHow many peaks are detected in this signal?
Using the following signal data, how many peaks does the peak detection algorithm find?
Signal Processing
import numpy as np from scipy.signal import find_peaks signal = np.array([0, 2, 1, 3, 7, 6, 5, 8, 4, 3, 2]) peaks, _ = find_peaks(signal) print(len(peaks))
Attempts:
2 left
💡 Hint
A peak is a point higher than its neighbors.
✗ Incorrect
The peaks are at indices 1 (2), 4 (7), and 7 (8), totaling 3 peaks.
❓ visualization
advancedWhich plot shows the frequency spectrum of the signal?
Given a time-domain signal, which plot correctly shows its frequency spectrum after applying Fourier Transform?
Signal Processing
import numpy as np import matplotlib.pyplot as plt signal = np.sin(2*np.pi*5*np.linspace(0,1,100)) + 0.5*np.sin(2*np.pi*10*np.linspace(0,1,100)) fft_vals = np.fft.fft(signal) freqs = np.fft.fftfreq(len(signal), d=0.01) plt.plot(freqs[:50], np.abs(fft_vals)[:50]) plt.xlabel('Frequency (Hz)') plt.ylabel('Amplitude') plt.title('Frequency Spectrum') plt.show()
Attempts:
2 left
💡 Hint
Fourier Transform reveals the frequencies present in the signal.
✗ Incorrect
The signal is composed of sine waves at 5 Hz and 10 Hz, so the frequency spectrum shows peaks at these frequencies.
🧠 Conceptual
advancedWhy do we transform signals from time domain to frequency domain?
What is the main reason for transforming signals from the time domain to the frequency domain in signal processing?
Attempts:
2 left
💡 Hint
Think about what information frequency domain reveals that time domain does not.
✗ Incorrect
Transforming to frequency domain helps us see which frequencies make up the signal, which is useful for analysis and filtering.
🔧 Debug
expertWhat error does this signal normalization code raise?
Consider this code to normalize a signal. What error occurs when running it?
Signal Processing
import numpy as np signal = np.array([0, 0, 0, 0]) normalized = (signal - np.min(signal)) / (np.max(signal) - np.min(signal)) print(normalized)
Attempts:
2 left
💡 Hint
Check what happens if max and min are equal in the denominator.
✗ Incorrect
Since all values are zero, max and min are equal, causing division by zero and raising ZeroDivisionError.
