Challenge - 5 Problems
Signal Processing Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Fourier Transform on a Simple Signal
What is the output magnitude array of the Fourier Transform applied to a simple sine wave signal?
SciPy
import numpy as np from scipy.fft import fft # Create a sine wave signal fs = 100 # Sampling frequency f = 5 # Frequency of sine wave x = np.linspace(0, 1, fs, endpoint=False) signal = np.sin(2 * np.pi * f * x) # Compute Fourier Transform fft_result = fft(signal) magnitude = np.abs(fft_result) print(magnitude[:10])
Attempts:
2 left
💡 Hint
Look for the peak magnitude at the frequency of the sine wave.
✗ Incorrect
The Fourier Transform of a sine wave at frequency f shows a peak magnitude at the corresponding frequency bin. The magnitude is approximately half the number of samples due to the FFT scaling.
❓ data_output
intermediate2:00remaining
Number of Peaks Detected in a Noisy Signal
Given a noisy signal with multiple peaks, how many peaks does the scipy.signal.find_peaks function detect?
SciPy
import numpy as np from scipy.signal import find_peaks np.random.seed(0) x = np.linspace(0, 6*np.pi, 1000) signal = np.sin(x) + 0.5 * np.sin(3*x) + 0.2 * np.random.normal(size=1000) peaks, _ = find_peaks(signal, height=0.5) print(len(peaks))
Attempts:
2 left
💡 Hint
Consider the combined frequencies and the threshold height parameter.
✗ Incorrect
The find_peaks function detects peaks above the height threshold. The combined sine waves produce multiple peaks, but only those above 0.5 are counted, resulting in 9 peaks.
❓ visualization
advanced3:00remaining
Visualizing the Effect of a Low-Pass Filter
Which plot correctly shows the effect of applying a low-pass Butterworth filter to a noisy signal?
SciPy
import numpy as np import matplotlib.pyplot as plt from scipy.signal import butter, filtfilt fs = 500 x = np.linspace(0, 1, fs, endpoint=False) signal = np.sin(2*np.pi*5*x) + 0.5*np.sin(2*np.pi*50*x) + 0.3*np.random.normal(size=fs) b, a = butter(4, 10, btype='low', fs=fs) filtered = filtfilt(b, a, signal) plt.figure(figsize=(10, 4)) plt.plot(x, signal, label='Noisy Signal') plt.plot(x, filtered, label='Filtered Signal', linewidth=2) plt.legend() plt.title('Low-Pass Filter Effect') plt.xlabel('Time [s]') plt.ylabel('Amplitude') plt.show()
Attempts:
2 left
💡 Hint
Low-pass filters remove high-frequency noise, leaving smooth low-frequency signals.
✗ Incorrect
A low-pass Butterworth filter removes high-frequency components, so the filtered signal is smoother and retains only low-frequency parts of the original signal.
🧠 Conceptual
advanced1:30remaining
Why Signal Processing Extracts Information
Why does signal processing help extract meaningful information from raw data?
Attempts:
2 left
💡 Hint
Think about how filtering and transformations help reveal hidden patterns.
✗ Incorrect
Signal processing techniques like filtering and transforms reduce noise and emphasize important patterns, making it easier to analyze and extract useful information.
🔧 Debug
expert2:30remaining
Identify the Error in Signal Filtering Code
What error does the following code produce when applying a Butterworth filter, and why?
import numpy as np
from scipy.signal import butter, filtfilt
fs = 100
x = np.linspace(0, 1, fs, endpoint=False)
signal = np.sin(2 * np.pi * 10 * x)
b, a = butter(4, 60, btype='low', fs=fs)
filtered_signal = filtfilt(b, a, signal)
print(filtered_signal[:5])
SciPy
import numpy as np from scipy.signal import butter, filtfilt fs = 100 x = np.linspace(0, 1, fs, endpoint=False) signal = np.sin(2 * np.pi * 10 * x) b, a = butter(4, 60, btype='low', fs=fs) filtered_signal = filtfilt(b, a, signal) print(filtered_signal[:5])
Attempts:
2 left
💡 Hint
Check the critical frequency relative to the sampling frequency.
✗ Incorrect
The critical frequency parameter must be less than half the sampling frequency (Nyquist frequency). Here, 60 is greater than fs/2=50, causing a ValueError.