0
0
SciPydata~20 mins

Inverse FFT (ifft) in SciPy - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Inverse FFT Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Inverse FFT on a Simple Array
What is the output of the following code that uses scipy.fft.ifft on a simple frequency domain array?
SciPy
from scipy.fft import ifft
import numpy as np
freq_data = np.array([4+0j, 0+0j, 0+0j, 0+0j])
time_data = ifft(freq_data)
print(np.round(time_data, decimals=2))
A[0.+0.j 0.+0.j 0.+0.j 0.+0.j]
B[4.+0.j 0.+0.j 0.+0.j 0.+0.j]
C[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
D[1.+0.j 1.+0.j 1.+0.j 1.+0.j]
Attempts:
2 left
💡 Hint
Recall that the inverse FFT converts frequency data back to time domain. The input array has only the zero frequency component.
data_output
intermediate
1:30remaining
Length of Output from ifft
Given a frequency domain array of length 8, what is the length of the output array after applying scipy.fft.ifft?
SciPy
from scipy.fft import ifft
import numpy as np
freq_data = np.arange(8) + 1j * np.zeros(8)
time_data = ifft(freq_data)
print(len(time_data))
A8
B7
C16
D4
Attempts:
2 left
💡 Hint
The inverse FFT output length matches the input frequency array length.
🧠 Conceptual
advanced
2:00remaining
Effect of Scaling in Inverse FFT
Which statement correctly describes the scaling behavior of scipy.fft.ifft compared to scipy.fft.fft?
AThe ifft output is the fft input squared element-wise.
BThe ifft output is the fft input divided by the length of the array.
CThe ifft output is the fft input unchanged in scale.
DThe ifft output is the fft input multiplied by the length of the array.
Attempts:
2 left
💡 Hint
Think about how the inverse FFT reverses the FFT operation including normalization.
🔧 Debug
advanced
2:00remaining
Identify the Error in ifft Usage
What error will this code raise when run?
from scipy.fft import ifft
import numpy as np
freq_data = [1, 2, 3]
time_data = ifft(freq_data, n=5)
print(time_data)
ANo error; outputs an array of length 5 with zero-padding
BTypeError: ifft() got an unexpected keyword argument 'n'
CValueError: n must be a positive integer and >= input length
DIndexError: list index out of range
Attempts:
2 left
💡 Hint
Consult the documentation or function signature for scipy.fft.ifft; it supports the n argument.
🚀 Application
expert
3:00remaining
Reconstructing a Signal from Frequency Components
You have frequency domain data representing a signal sampled at 8 points: [4+0j, 1-1j, 0+0j, 1+1j, 0+0j, 1-1j, 0+0j, 1+1j]. Using scipy.fft.ifft, what is the real part of the time domain signal rounded to two decimals?
SciPy
from scipy.fft import ifft
import numpy as np
freq_data = np.array([4+0j, 1-1j, 0+0j, 1+1j, 0+0j, 1-1j, 0+0j, 1+1j])
time_data = ifft(freq_data)
real_time = np.round(time_data.real, 2)
print(real_time)
A[4. 1. 0. 1. 0. 1. 0. 1.]
B[0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5]
C[1. 0.5 1. 0.5 0. 0.5 1. 0.5]
D[1. 1. 1. 1. 1. 1. 1. 1.]
Attempts:
2 left
💡 Hint
The inverse FFT reconstructs the time signal; the imaginary parts should be near zero due to symmetry.