【发布时间】:2018-01-07 01:21:16
【问题描述】:
我正在学习如何使用 numpy 进行快速傅里叶变换微分。在下面的代码中,我创建了一个简单的正弦函数并尝试获取余弦。结果显示在图像中,似乎有一个标准化因素,尽管阅读了文档,但我还是不明白,这使我无法获得正确的结果。
你能告诉我如何摆脱标准化因素,或者我是否以不同的方式失败? 另请解释为什么当数组长度为奇数时不存在奈奎斯特频率。
x = np.arange(start=-300., stop=300.1, step=0.1)
sine = np.sin(x)
Y = np.fft.rfft(a=sine, n=len(x))
L = 2.*np.pi #period
N = size(Y)
for k, y in enumerate(Y):
Y[k] *= 2.*np.pi*1j*k/L
# if N is even, the last entry is the Nyquist frequency.
#if N is odd, there it is not there.
if N%2 == 0:
Y[-1] *= 0.
cosine = np.fft.irfft(a=Y, n=len(x))
【问题讨论】:
标签: python numpy fft derivative