为什么对于单个频率的样本,FFT结果显示2个非零幅度? [英] Why do FFT result show 2 non-zero amplitudes for a samples of single frequency?
问题描述
通过简单的FFT运行来学习操作,我创建了一个NumPy数组,其中包含100个元素,它们的正弦波在数组中只有一个周期.使用此代码:
Doing a simple FFT run to learn the operation, I create an NumPy array with 100 elements having a sine wave with only a single period in the array. This code is used:
...
n = 100
x = np.fromfunction(lambda a: np.sin(2 * np.pi * a / n), (n,), dtype=float)
res = np.fft.fft(x)
...
res
中的结果在两个不同的索引值处显示了一个非零幅度:
The result in res
shows an non-zero amplitude at 2 different index value:
idx real imag abs
--- ---------- ---------- ----------
...
1: 0 -50.000 50.000
...
99: 0 50.000 50.000
我只期望在索引1处看到一个非零振幅.
I had only expected to see a single non-zero amplitude at index 1.
为什么索引1和99的幅度都非零,我如何从数学上理解这一点?
Why is amplitude non-zero for both index 1 and 99, and how can I understand this mathematically?
添加:也许高频实际上代表了混叠" 的频率,根据奈奎斯特汇率,汇率太低.
ADDITION: Maybe the high frequency actually represent an aliased frequency, where the sample rate is too low according to the Nyquist rate.
推荐答案
傅立叶变换
其中Xk
是复数.当您的x
是实数时,结果是X[N-m] = X[m]*
,对于您来说,N=100, m=1
,因此,您有X[ 1 ] = X[99]
where Xk
are complex numbers. While your x
are real numbers, as a result, you get X[N-m] = X[m]*
In your case, N=100, m=1
, therefore, you have X[ 1 ] = X[99]
下面的链接介绍了所有内容,
The link below explains everything,
在处理实数时,numpy
提供了另一个功能numpy.fft.rfft
When dealing with real numbers, numpy
provides another function numpy.fft.rfft
当为纯实数输入计算DFT时,输出是Hermitian对称的,即负频率项只是相应正频率项的复共轭,因此负频率项是多余的.此函数不计算负频率项,因此输出的变换轴的长度为n//2 + 1.
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.
这篇关于为什么对于单个频率的样本,FFT结果显示2个非零幅度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!