Frequency analysis
Analyze the frequency components of a sampled time-domain signal.
SciPy · Function
Computes a one-dimensional discrete Fourier Transform using the Fast Fourier Transform algorithm. You can control output length, transformed axis, normalization, and optional parallel execution.
fft converts an input sequence into its one-dimensional discrete Fourier Transform using the Fast Fourier Transform algorithm. The transformed length defaults to the selected axis length, while n can crop or zero-pad that axis; norm selects how scaling is distributed between forward and inverse transforms.
scipy.fft.fft(x, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, *, plan=None)| Name | Type | Description |
|---|---|---|
x | array_like | Input array, which may contain complex values. |
n | int, optional | Length of the transformed axis. If shorter than the input it crops; if longer it zero-pads; if omitted it uses that axis's length. |
axis | int, optional | Axis over which to compute the FFT; defaults to the last axis. |
norm | {“backward”, “ortho”, “forward”}, optional | Normalization mode: “backward”, “ortho”, or “forward”. |
overwrite_x | bool, optional | Whether the input may be overwritten for performance. |
workers | int, optional | Number of workers to use for parallel computation. |
plan | object, optional | Reserved for passing a vendor-specific FFT plan; currently not used. |
The transformed array containing the one-dimensional discrete Fourier Transform of x.
import numpy as np
from scipy.fft import fft
samples = np.array([1.0, 0.0, -1.0, 0.0])
spectrum = fft(samples)
print(spectrum)Transforms a short real-valued signal into its complex frequency-domain representation.
Analyze the frequency components of a sampled time-domain signal.
Transform multidimensional data one row or column at a time.
Control spectral resolution or input length by cropping or zero-padding.
fft computes a one-dimensional discrete Fourier Transform with the efficient Fast Fourier Transform algorithm. It returns the frequency-domain representation of the supplied array.
Follow-up: How does n affect the calculation? It determines the transformed-axis length: a shorter value crops the input, and a longer value zero-pads it.
The axis argument selects the dimension to transform and defaults to the last axis. This allows FFTs to be applied independently across other dimensions.
Follow-up: What happens when axis is omitted? SciPy uses the final axis of the input array.
norm controls scaling, with backward, ortho, and forward modes available. backward is the default; it leaves the forward transform unscaled and scales ifft by 1/n.
Follow-up: Which mode scales the forward transform? forward applies the 1/n factor on the forward transform.
ifftfftnrfftnext_fast_len