What is the main purpose of the Discrete Fourier Transform (DFT)?
The DFT converts a sequence of values from the time domain into the frequency domain, showing how much of each frequency is present in the original signal.
Click to reveal answer
intermediate
Write the formula for the Discrete Fourier Transform (DFT).
X[k] = \sum_{n=0}^{N-1} x[n] \cdot e^{-i 2 \pi k n / N}, where N is the number of samples, x[n] is the input signal, and X[k] is the frequency component.
Click to reveal answer
beginner
What does the output of the DFT represent?
The output is a set of complex numbers representing the amplitude and phase of different frequency components in the input signal.
Click to reveal answer
intermediate
Why do we use complex numbers in the DFT?
Complex numbers allow the DFT to capture both amplitude and phase information of each frequency component, which is essential for reconstructing the original signal.
Click to reveal answer
intermediate
How does the number of samples N affect the DFT?
The number of samples N determines the frequency resolution and the number of frequency components the DFT produces. More samples mean finer frequency detail.
Click to reveal answer
What does the DFT transform a signal from and to?
AAmplitude domain to phase domain
BFrequency domain to time domain
CSpatial domain to time domain
DTime domain to frequency domain
✗ Incorrect
The DFT converts signals from the time domain into the frequency domain.
In the DFT formula, what does the term e^{-i 2 \pi k n / N} represent?
AA complex sinusoid at frequency k
BA real number scaling factor
CThe input signal value
DThe output frequency magnitude
✗ Incorrect
It represents a complex sinusoid used to extract the frequency component k.
What kind of numbers does the DFT output?
AIntegers
BReal numbers only
CComplex numbers
DBinary values
✗ Incorrect
The DFT outputs complex numbers representing amplitude and phase.
Increasing the number of samples N in DFT results in:
AHigher frequency resolution
BFewer frequency components
CLower frequency resolution
DNo change in frequency resolution
✗ Incorrect
More samples give finer frequency resolution in the DFT.
Which of these is NOT a use of the DFT?
AAnalyzing audio signals
BSorting numbers
CImage compression
DDetecting frequencies in data
✗ Incorrect
Sorting numbers is unrelated to frequency analysis done by the DFT.
Explain in your own words what the Discrete Fourier Transform (DFT) does and why it is useful.
Think about how music can be broken down into notes.
You got /3 concepts.
Describe how the number of samples affects the DFT output and what happens if you increase or decrease it.
Consider how zooming in or out changes what you see.
You got /3 concepts.
Practice
(1/5)
1. What does the Discrete Fourier Transform (DFT) primarily do to a signal?
easy
A. Converts the signal from time domain to frequency domain
B. Amplifies the signal amplitude
C. Filters out noise from the signal
D. Compresses the signal data size
Solution
Step 1: Understand signal domains
The time domain shows how a signal changes over time, while the frequency domain shows the signal's frequency components.
Step 2: Role of DFT
DFT transforms a signal from the time domain into the frequency domain, revealing hidden frequencies.
Final Answer:
Converts the signal from time domain to frequency domain -> Option A
Quick Check:
DFT = Time to Frequency [OK]
Hint: DFT = time to frequency conversion [OK]
Common Mistakes:
Thinking DFT amplifies signals
Confusing DFT with noise filtering
Assuming DFT compresses data
2. Which of the following is the correct Python syntax to compute the DFT of a 1D array signal using numpy?
easy
A. numpy.dft(signal)
B. numpy.fft.fft(signal)
C. numpy.fft.dft(signal)
D. numpy.fft.transform(signal)
Solution
Step 1: Identify numpy FFT function
In numpy, the function to compute the Discrete Fourier Transform is fft inside the fft module.
Step 2: Check correct syntax
The correct call is numpy.fft.fft(signal). Other options are either non-existent or incorrect function names.
Final Answer:
numpy.fft.fft(signal) -> Option B
Quick Check:
Use numpy.fft.fft() for DFT [OK]
Hint: Use numpy.fft.fft() to compute DFT [OK]
Common Mistakes:
Using nonexistent numpy.dft() function
Confusing module and function names
Typing transform instead of fft
3. Given the Python code:
import numpy as np
signal = np.array([1, 0, -1, 0])
dft_result = np.fft.fft(signal)
print(np.round(dft_result, 2))
What is the output?
medium
A. [0.+0.j 0.+2.j 0.+0.j 0.-2.j]
B. [0.+0.j 0.+0.j 0.+0.j 0.+0.j]
C. [0.+0.j 2.+0.j 0.+0.j 2.+0.j]
D. [0.+0.j 1.+0.j 0.+0.j 1.+0.j]
Solution
Step 1: Understand input signal
The signal is [1, 0, -1, 0], a simple 4-point sequence alternating positive and negative values.
Step 2: Compute DFT manually or recall pattern
DFT of this sequence results in complex values showing frequency components. The output is [0.+0.j, 0.+2.j, 0.+0.j, 0.-2.j] after rounding.
Final Answer:
[0.+0.j 0.+2.j 0.+0.j 0.-2.j] -> Option A
Quick Check:
DFT of alternating signal = complex freq components [OK]
Hint: Look for imaginary parts in DFT of alternating signals [OK]
Common Mistakes:
Ignoring imaginary parts in output
Confusing zero arrays with actual DFT
Misreading numpy rounding output
4. Identify the error in this Python code snippet for computing DFT:
import numpy as np
signal = [1, 2, 3, 4]
dft = np.fft.fft(signal, n=2)
print(dft)
medium
A. np.fft.fft does not accept the parameter n
B. The signal must be a numpy array, not a list
C. The parameter n=2 truncates the DFT length incorrectly
D. The print statement syntax is incorrect
Solution
Step 1: Understand parameter n in np.fft.fft
The parameter n sets the length of the DFT. If shorter than signal length, signal is truncated.
Step 2: Effect of n=2 on signal length 4
Setting n=2 truncates the signal from length 4 to 2, losing data and changing the DFT result unexpectedly.
Final Answer:
The parameter n=2 truncates the DFT length incorrectly -> Option C
Quick Check:
n parameter truncates or pads signal [OK]
Hint: Check if n parameter matches signal length [OK]
Common Mistakes:
Assuming n pads signal always
Thinking signal must be numpy array
Believing np.fft.fft disallows n parameter
5. You have a noisy signal sampled at 8 points: [1, 0, 1, 0, 1, 0, 1, 0]. You want to remove high-frequency noise by zeroing out the last 4 DFT coefficients and then reconstruct the signal using inverse DFT. Which Python code snippet correctly performs this?
hard
A. dft = np.fft.fft(signal)
dft[0:4] = 0
clean_signal = np.fft.ifft(dft).real
B. dft = np.fft.fft(signal)
dft[:4] = 0
clean_signal = np.fft.ifft(dft).real
C. dft = np.fft.fft(signal)
dft[2:] = 0
clean_signal = np.fft.ifft(dft).real
D. dft = np.fft.fft(signal)
dft[4:] = 0
clean_signal = np.fft.ifft(dft).real
Solution
Step 1: Compute DFT of signal
Use np.fft.fft(signal) to get frequency components.
Step 2: Zero out last 4 coefficients to remove high frequencies
Since signal length is 8, last 4 coefficients are dft[4:]. Setting them to zero removes high-frequency noise.
Step 3: Reconstruct signal with inverse DFT
Use np.fft.ifft(dft).real to get cleaned time-domain signal.