np.fft.irfft()中的归一化因子是什么?

时间:2014-05-29 23:45:19

标签: python numpy fft

我正在使用np.fft.irfft()作为计算Wigner分布的程序的一部分。由于我不想要fft的规范化版本,我需要规范化因子来“撤销”规范化。

np.fft.irfft()的规范化因素是什么?

1 个答案:

答案 0 :(得分:1)

我相信numpy.fft.irfft的范数在数组长度上是1。要考虑以下程序:

import numpy as np

t = np.array([0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
x = np.fft.irfft(t)

print  "Array length: ", len(t), "\t 1/n: ", 1.0/float(len(t)), "\t max x val: ", max(x)


x1 = np.array([0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])

t1 = np.fft.rfft(x1)

print  "Array length: ", len(t1), "\t 1/n: ", 1.0/float(len(t1)), "\t max t1 val: ", max(t1)

输出:

Array length:  128   1/n:  0.0078125     max x val:  0.00787401574803
Array length:  65    1/n:  0.0153846153846   max t1 val:  (1+0j)

据此我认为,irfft的范数是1 / n,而rfft则是1.这将与reference一致(参见实施细节)。