title: (numpy) Wrong amplitude(?) of FFT'd array?
body: <p>I'm using numpy and matplotlib to analyze data output form my simulations. There is one (apparent) inconsistency that I can't find the roots of. It's the following:</p>
  
  <p>I have a signal that has a given energy a^2~1. When I use rfft to take the FFT and compute the energy in the Fourier space, it comes out to be significantly larger. To void giving the details of my data etc., here is an example with a simple sin wave:</p>
  
  <pre><code>from pylab import *
  xx=np.linspace(0.,2*pi,128)
  a=np.zeros(128)
  for i in range(0,128):
      a[i]=sin(xx[i])
  aft=rfft(a)
  print mean(abs(aft)**2),mean(a**2) 
  </code></pre>
  
  <p>In principle both the numbers should be the same (at least in the numerical sense) but this is what I get out of this code:</p>
  
  <pre><code>62.523081632 0.49609375
  </code></pre>
  
  <p>I tried to go through numpy.fft documentation but could not find anything. A search here gave the following but I was not able to understand the explanations there:</p>
  
  <p><a href="https://stackoverflow.com/questions/14936359/big-fft-amplitude-difference-between-the-existing-synthesized-signal-and-the-f">Big FFT amplitude difference between the existing (synthesized) signal and the filtered signal</a></p>
  
  <p>What am I missing/ misunderstanding? Any help/ pointer in this regard would be greatly appreciated.</p>
  
  <p>Thanks!</p>