FFT stands for Fast Fourier Transform. It is used to convert a signal from its original time or space domain into a frequency domain representation.
Click to reveal answer
beginner
What is the purpose of the np.fft.fft() function in numpy?
np.fft.fft() computes the one-dimensional discrete Fourier Transform of a sequence, turning time-based data into frequency-based data.
Click to reveal answer
intermediate
How do you interpret the output of np.fft.fft()?
The output is a complex array where each element represents amplitude and phase of a frequency component. The magnitude shows strength, and the angle shows phase shift.
Click to reveal answer
beginner
What does np.fft.ifft() do?
np.fft.ifft() computes the inverse FFT, converting frequency domain data back to the original time or space domain signal.
Click to reveal answer
intermediate
Why is zero-padding used before applying FFT?
Zero-padding adds zeros to the end of a signal to increase its length, which can improve frequency resolution and make the FFT output easier to interpret.
Click to reveal answer
What type of data does np.fft.fft() transform?
AFrequency domain data
BTime or space domain data
CCategorical data
DText data
✗ Incorrect
np.fft.fft() transforms time or space domain data into frequency domain data.
What does the magnitude of the FFT output represent?
AStrength of each frequency component
BPhase shift of the signal
CTime duration of the signal
DSampling rate
✗ Incorrect
The magnitude shows how strong each frequency component is in the original signal.
Which numpy function converts frequency domain data back to time domain?
Anp.fft.ifft()
Bnp.fft.rfft()
Cnp.fft.fft()
Dnp.fft.fftn()
✗ Incorrect
np.fft.ifft() is the inverse FFT function.
What is the effect of zero-padding a signal before FFT?
ARemoves noise
BDecreases frequency resolution
CChanges the signal amplitude
DIncreases frequency resolution
✗ Incorrect
Zero-padding increases the length of the signal, improving frequency resolution in the FFT output.
What kind of numbers does FFT output contain?
AReal numbers only
BBoolean values
CComplex numbers
DIntegers only
✗ Incorrect
FFT output is complex numbers representing amplitude and phase.
Explain in simple terms what FFT does and why it is useful.
Think about how music or sound can be broken down into notes.
You got /3 concepts.
Describe how you would use numpy's FFT functions to analyze a signal and then reconstruct it.
Consider the steps from time data to frequency and back.
You got /3 concepts.
Practice
(1/5)
1. What does the np.fft.fft() function do in numpy?
easy
A. It calculates the mean of an array.
B. It sorts an array in ascending order.
C. It generates random numbers.
D. It computes the Fast Fourier Transform of a signal.
Solution
Step 1: Understand the purpose of FFT
FFT converts time-domain data into frequency-domain data quickly.
Step 2: Identify the function role
np.fft.fft() computes this Fast Fourier Transform on input data.
Final Answer:
It computes the Fast Fourier Transform of a signal. -> Option D
Quick Check:
FFT = Fast Fourier Transform [OK]
Hint: FFT = Fast Fourier Transform, converts time to frequency [OK]
Common Mistakes:
Confusing FFT with sorting or averaging functions
Thinking FFT generates random data
Mixing FFT with statistical calculations
2. Which of the following is the correct syntax to compute the FFT of a numpy array data?
easy
A. np.fft(data).fft()
B. np.fft.fft(data)
C. fft(np.data)
D. np.fft_fft(data)
Solution
Step 1: Recall numpy FFT syntax
The correct function call is np.fft.fft() with the data array as argument.
Step 2: Check each option
Only np.fft.fft(data) matches the correct syntax; others are invalid or incorrect.
Final Answer:
np.fft.fft(data) -> Option B
Quick Check:
Correct function call = np.fft.fft(data) [OK]
Hint: Use np.fft.fft(array) to compute FFT [OK]
Common Mistakes:
Swapping function and module order
Using wrong function names
Passing wrong argument types
3. What is the output of the following code?
import numpy as np
x = np.array([1, 0, 0, 0])
fft_x = np.fft.fft(x)
print(np.round(fft_x, 2))
medium
A. [1.+0.j 0.+0.j 0.+0.j 0.+0.j]
B. [1.+0.j 1.+0.j 1.+0.j 1.+0.j]
C. [4.+0.j 0.+0.j 0.+0.j 0.+0.j]
D. [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
Solution
Step 1: Understand input signal
The input array has one '1' followed by zeros, representing a unit impulse (delta function).
Step 2: Compute FFT of impulse
The FFT of a unit impulse of length 4 is [4.+0.j 0.+0.j 0.+0.j 0.+0.j], because the sum of the input is 1 at position 0, but the FFT sums all elements, so the DC component is 4.
Final Answer:
[4.+0.j 0.+0.j 0.+0.j 0.+0.j] -> Option C
Quick Check:
Impulse FFT = DC component equals sum of input [OK]
Hint: FFT of unit impulse = all ones [Incorrect], actually FFT of [1,0,0,0] = [4,0,0,0] [OK]
Common Mistakes:
Thinking FFT shows sum only at DC ([4.+0.j 0.+0.j 0.+0.j 0.+0.j])
Ignoring complex number format
Misreading array rounding
4. Identify the error in this code snippet:
import numpy as np
signal = [1, 2, 3, 4]
fft_signal = np.fft.fft(signal, n=-1)
print(fft_signal)
medium
A. The FFT length n cannot be smaller than the input length.
B. The print statement syntax is incorrect.
C. The function np.fft.fft does not accept the parameter n.
D. The input signal must be a numpy array, not a list.
Solution
Step 1: Check FFT length parameter
The input signal length is 4, but n=-1 is smaller than input length.
Step 2: Understand FFT behavior with n parameter
FFT length n must be at least the input length or zero-padded; smaller n truncates data causing error or unexpected results.
Final Answer:
The FFT length n cannot be smaller than the input length. -> Option A
Quick Check:
FFT length n ≥ input length [OK]
Hint: FFT length n ≥ input length [OK]
Common Mistakes:
Thinking lists are invalid input
Believing n can be any number
Assuming print syntax error
5. You have a noisy signal stored in a numpy array noisy_signal. You want to remove high-frequency noise by zeroing FFT components above index 5. Which code correctly applies this filter and returns the cleaned signal?
hard
A. fft_vals = np.fft.fft(noisy_signal)
fft_vals[5:] = 0
clean_signal = np.fft.ifft(fft_vals).real
B. fft_vals = np.fft.fft(noisy_signal)
fft_vals[:5] = 0
clean_signal = np.fft.ifft(fft_vals).real
C. fft_vals = np.fft.ifft(noisy_signal)
fft_vals[5:] = 0
clean_signal = np.fft.fft(fft_vals).real
D. clean_signal = np.fft.fft(noisy_signal)
clean_signal[5:] = 0
Solution
Step 1: Compute FFT of noisy signal
Use np.fft.fft(noisy_signal) to get frequency components.
Step 2: Zero out high-frequency components
Set FFT values from index 5 onward to zero to remove high frequencies.
Step 3: Compute inverse FFT to get cleaned signal
Apply np.fft.ifft() and take real part to get filtered time-domain signal.