Dan
Dan

Reputation: 12675

What is the normalization factor in np.fft.irfft()?

I'm using np.fft.irfft() as part of a program to calculate the Wigner distribution. Since I don't want the normalized version of the fft, I need the normalization factor to "undo" the normalization.

What is the normalization factor for np.fft.irfft()?

Upvotes: 0

Views: 868

Answers (1)

user3413108
user3413108

Reputation:

I believe the norm of numpy.fft.irfft is 1 over array length. To see that consider the following program:

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)

This outputs:

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

From this I believe that the norm of the irfft is 1/n and from rfft it is 1. This would be in accordance with this reference (see Implementation details).

Upvotes: 1

Related Questions