Parseval's Theorem on a Random Signal 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:

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

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!
 A: 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!
