gpt4 book ai didi

python - numpy.fft.fft 和 numpy.fft.rfft 有什么区别?

转载 作者:太空宇宙 更新时间:2023-11-03 12:53:30 25 4
gpt4 key购买 nike

文档说 np.fft.fft 这样做:

Compute the one-dimensional discrete Fourier Transform.

np.fft.rfft 这样做:

Compute the one-dimensional discrete Fourier Transform for real input.

我还看到,对于我的数据(音频数据,实值),np.fft.fft 返回一个包含复数的二维形状数组 (number_of_frames, fft_length)。

对于 np.fft.rfft 返回包含复数的二维形状数组 (number_of_frames, ((fft_length/2) + 1))。我被引导相信这只包含非冗余 FFT bin

有人可以更深入地解释命令之间的区别以及返回数组的形状不同的原因。谢谢。

最佳答案

文档中解释了原因:

When the DFT is computed for purely real input, the output is Hermitian-symmetric, i.e. the negative frequency terms are just the complex conjugates of the corresponding positive-frequency terms, and the negative-frequency terms are therefore redundant. This function does not compute the negative frequency terms, and the length of the transformed axis of the output is therefore n//2 + 1.

因此,算法得到了优化,rfft 的速度提高了一倍。此外,频谱更容易绘制:

In [124]: s=abs(sin(arange(0,2**13,3)))

In [125]: sp=rfft(s)

In [126]: plot(abs(sp))

enter image description here

关于python - numpy.fft.fft 和 numpy.fft.rfft 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52387673/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com