Parseval's Theorem Doesn't Work With Ifft
I have a temporal signal and I calculate its Fourier Transform to get the frequencial signal. According to Parseval's theorem, the two signals have the same energy. I successfully
Solution 1:
The numpy
FFT procedures actually and in contrast to other software do adjust for the sequence length, so that you get
nf.ifft(nf.fft(gx)) == gx
up to some floating point error. If your dx
and dk
are computed the usual way, then dk*dx=(2*pi)/N
which only works for unadjusted FFT routines.
You can test the behavior of numpy.fft
using
In [20]: sum(abs(gx)**2.0)
Out[20]: 35.226587122763036
In [21]: gk = nf.fft(gx)
In [22]: sum(abs(gk)**2.0)
Out[22]: 35226.587122763049
In [23]: sum(abs(nf.ifft(gk))**2.0)
Out[23]: 35.226587122763014
which tells us that the fft
is the usual unadjusted transform and ifft
divides the result by sequence length N=num
. The typical ifft
can be emulated by
gxx = (nf.fft(gk.conj())).conj()
then you get that
gx == gxx/1000
up to floating point errors. Or you can reverse the adjustment using
#inverse FTgx_ = nf.ifft(nf.ifftshift(gkk))*(num*dk)/(2 * np.pi)**0.5
Post a Comment for "Parseval's Theorem Doesn't Work With Ifft"