1
$\begingroup$

NB - I'm re-posting this question in physics because I haven't had any luck getting a response from the maths StackExchange site - it's a rather applied problem so is probably better suited here anyway.

**

I'm struggling with Parseval's Theorem. I'm trying to relate variation in the time domain to the average value in the frequency domain. To do this, I'm performing the Fourier Transform on an arbitary random signal that I've generated with 2048 points (although the graph below only shows 100 of them) and a standard distribution (in this particular case) of 0.58:

Time domain trace of random signal - NB only showing 100 of 2048 points!

The frequency domain, after an FFT, then looks like this:

Frequency domain trace of random signal

with an average value of 0.022 - although this depends on the number of samples used.

Now when I try to apply Parseval's Theorem, where:

$\sum_{n=0}^{N-1} |x[n]|^2 = \frac{1}{N}\sum_{n=0}^{N-1} |X[k]|^2 $

I run into a problem. When I do the summations, I get 678 for the time domain and 0.662 for the frequency domain. When I apply the factor of $1/N$ I end up with 0.0003 for the frequency side - clearly a long way off!

Obviously I'm going wrong somewhere, but can't see where. This many orders of magnitudes off isn't very encouraging...

Thanks for your help!

$\endgroup$
  • $\begingroup$ It appears that the time domain sum is larger by (2048)(1024). Those numbers seem significant to me. Have you tried this on other, non-random signals? $\endgroup$ – Alfred Centauri Jul 22 '13 at 16:17
  • $\begingroup$ Hi Alfred, I've just tried for a sin wave - I get sensible looking results with a peak at the right position in frequency space, but again running into the time domain vs freq domain issue with Parseval's Theorem. On the LHS I'm getting 1024 (as you'd expect given that the time average of sin is 1/2 and it's 2048 points long) and the RHS is giving me exactly 1/2048. So it seems like the (2048)(1024) factor is not specific to random signals... $\endgroup$ – Ned Yoxall Jul 22 '13 at 18:47
  • $\begingroup$ On further thought, it seems to me that to properly describe the actual trace in time (i.e. before and after the start and end of the signal have to be zero), one would need more high frequency components. So perhaps the issue here is with the form of Parseval's Theorem I'm trying to apply? $\endgroup$ – Ned Yoxall Jul 22 '13 at 19:26
  • $\begingroup$ IIRC (it has been a while since I've looked at some of this), the 2048 point DFT of your 2048 point time domain signal is a sampled DTFT of a periodic version of your time signal (see, for example: blogs.mathworks.com/steve/2010/03/15/the-dft-and-the-dtft). So, I think Parseval's still applies. I smell some sort of normalization issue. What package are you using? $\endgroup$ – Alfred Centauri Jul 22 '13 at 19:39
  • $\begingroup$ Python - the scipy.fftpack.fft version. I think you're right - normalization seems to be the buzzword to google regarding this. The factor of 2 (meaning that it's (2048)(1024) not (2048)(2048)) is coming from the fact that I'm only summing over positive frequencies on the RHS. Getting closer to the answer! $\endgroup$ – Ned Yoxall Jul 22 '13 at 20:30
2
$\begingroup$

OK, with a lot of help from Alfred Centauri (huge thanks), I've twigged it. The problem revolves around normalization and the length of the arrays. If you're struggling with applying Parseval's Theorem and your time and frequency arrays are different lengths, this is probably the issue!

So... in line with a lot of FFT algorithms that want to have a meaningful connection between amplitudes in time and frequency (see here), my output wasn't given by the "standard wikipedia" transform, but instead by the following:

$$ X[k] = \frac{2}{N}\sum_{n=0}^{N-1} x_n \cdot\mathrm e^{-\mathrm i 2 \pi k n / N} $$

where the critical points are the $2/N$ factor at the front and the fact that $k$ is no longer from $0$ to $N-1$ but now from $0$ to $(N-1)/2$ i.e. half the length. Physically this corresponds to only including the positive frequencies which is prettier for graphing etc. The DC component is the only one that is not doubled in doing so, so for $X[0]$ you need to leave out the factor 2 in the equation above.

Now if you put this definition of the FFT outcome into the form of Parseval's Theorem I've given above (in the question) and remember that you need to double the outcome to account for array being half the length, you end up with this modified definition:

$$\sum_{n=0}^{N-1} |x[n]|^2 = \frac{N}{2}\sum_{k=1}^{N/2-1} |X[k]|^2 + N X[0]^2 $$

which perfectly fits my data. Nice when things (finally) work!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.