1

So I am working with DFTs for the first time and I have some problems. I have a discrete signal to this signal i want to apply a DFT, then I want to use the output in an integral.

So $S(t)$ is my signal, given on some interval T, and $F(f)$ is my DFT of $S$. I want to evaluate an integral on the form: $\int \frac{F(f)^2}{g(f)}$ where $g(f)$ is some well behaved function.

The my results were not what I expected so I decided to have a closer look at the transforms. I find that the discrete version of Parseval's theorem holds. In other words: $\sum_{n=0}^{N-1} |S_n|^2 = \frac{1}{N} \sum_{k=0}^{N-1} |F_k|^2.$

Naively i try to interpolate my $F_n^2$ and $S_n^2$ and expect that $\int_{-\infty}^{\infty} |S(t)|^2dx = \int_{-\infty}^{\infty}|F(f)|^2 df$ should hold. This do not hold.

So my question is, why is this not the case and how should I then evaluate my integral? My idea is that there is something wrong because the theorem holds for an infinite interval, but I try to convert it in to a finite one.

EDIT:

Think i got it worked out. One needs to normalize with a factor $T^2/N^2$ where N is the length of the interval and T is the time window. The math to work it out was not to hard, but I was just looking at it wrong.

PS: I am using python and i wrote a small test code to test my FFT code. The sum is the same for any function and N, but the integral fails.

N = 2052
t = numpy.linspace(-60.0,60.0,N)
y = (numpy.sin(t)*numpy.exp(-t**2))

dt = numpy.abs(max(t) - min(t))/N
freks = fftshift(numpy.fft.fftfreq(N, d=dt))

fft1 = fftshift(fft(y))
fft2 = numpy.abs(fft1)**2


tint = UnivariateSpline(t,numpy.abs(y)**2)
ftint = UnivariateSpline(freks,fft2)


g2 = lambda x:tint(x)
g21 = integrate.quad(g2,min(t),(max(t)),limit=10000, epsabs=1.49e-05, epsrel=1.49e-05)

g = lambda x:ftint(x)
g1 = integrate.quad(g,min(freks),(max(freks)),limit=10000, epsabs=1.49e-05, epsrel=1.49e-05)

tsum = numpy.sum(numpy.abs(y)**2)
fsum = 1/N* numpy.sum(fft2)
print(tsum,fsum)
print(g1[0],g21[0])
HaakonA
  • 305
  • 1
  • 10

0 Answers0