Challenge - 5 Problems
Real FFT Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of rfft on a simple signal
What is the output of the following code that uses
scipy.fft.rfft on a simple signal array?SciPy
import numpy as np from scipy.fft import rfft signal = np.array([1, 2, 3, 4]) result = rfft(signal) print(result)
Attempts:
2 left
💡 Hint
Remember that rfft returns the positive frequency terms including zero frequency.
✗ Incorrect
The rfft of [1,2,3,4] sums to 10 at zero frequency. The other terms are computed as complex numbers representing frequency components. The correct output matches option A.
❓ data_output
intermediate1:30remaining
Length of rfft output array
Given a real input array of length 10, what is the length of the output array from
scipy.fft.rfft?SciPy
import numpy as np from scipy.fft import rfft signal = np.arange(10) result = rfft(signal) print(len(result))
Attempts:
2 left
💡 Hint
The length of rfft output is N//2 + 1 for input length N.
✗ Incorrect
For input length 10, rfft returns 10//2 + 1 = 6 complex numbers representing frequencies from 0 to Nyquist.
❓ visualization
advanced3:00remaining
Visualizing magnitude spectrum from rfft
Which code snippet correctly plots the magnitude spectrum of a real signal using
scipy.fft.rfft and matplotlib?Attempts:
2 left
💡 Hint
Use rfftfreq with the correct sample spacing and plot the magnitude (absolute value) of rfft output.
✗ Incorrect
Option D correctly uses np.fft.rfftfreq with sample spacing 1/100, computes magnitude with np.abs, and plots frequency vs magnitude. Other options misuse frequency calculation or plot complex values directly.
🔧 Debug
advanced1:30remaining
Error raised by incorrect rfft usage
What error will this code raise when run?
SciPy
from scipy.fft import rfft signal = 'not an array' result = rfft(signal)
Attempts:
2 left
💡 Hint
rfft expects a numeric array, not a string.
✗ Incorrect
Passing a string to rfft causes a TypeError when numpy tries to multiply string by int internally during FFT computation.
🧠 Conceptual
expert2:00remaining
Understanding output symmetry of rfft
Which statement correctly describes the output of
scipy.fft.rfft compared to the full FFT of a real-valued input?Attempts:
2 left
💡 Hint
Think about how real input signals produce symmetric FFT outputs.
✗ Incorrect
rfft returns N//2+1 complex numbers representing frequencies from zero to Nyquist frequency, using symmetry of real inputs to reduce output size.