<DIV>Hi again, is there a good reason why the output is dependant upon the sampling rate. in the example if you increase from say 64 to 128 samples the output increases by a factor of 2.</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR><B><I>Christian Meesters &lt;meesters@uni-mainz.de&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Hi Jeff,<BR><BR>On 3 Aug 2005, at 02:03, Jeff Peery wrote:<BR>&gt; hope this is more clear. from the output I would expect that two <BR>&gt; spikes appear with amplitude = 1.&nbsp;<BR>[snip]<BR>&gt; I don't understand the output amplitudes. they should all be zero <BR>&gt; except for at one herz it should be one. not sure about the frequency <BR>&gt; for that matter either. I gotta dig up my math book and figure this <BR>&gt; out. in the meantime any suggestions for what this is outputing would <BR>&gt; be greatly appreciated! thanks.<BR>&gt; &nbsp;<BR><BR>Yes, well, the math book idea might be a good one ;-). No, but <BR>seriously: You are just making a little mistake. First of all you are <BR>NOT exactly calculating a Fourier transform but a numerical estimation <BR>of it (you are dealing with an array of discrete data points, which is <BR>unavoidable when dealing with computers
 ;-)). Look on your sine wave. <BR>Is it a perfect one? Then, what do you see when you plot your data? <BR>Some 'noise' and one little peak. The noise is due to errors which have <BR>to do with floating point arithmetics (see <BR>http://docs.python.org/tut/node16.html). It's really small and in most <BR>cases I'm sure it's neglectable as well.<BR>But when looking on your idea of what you would expect, I'm wondering <BR>whether you actually want a power spectrum estimation (see <BR>http://mathworld.wolfram.com/PowerSpectrum.html)? Try<BR><BR>myFFT = abs(fft.fft(inp))<BR><BR>instead of<BR><BR>myFFT = fft.real_fft(inp)<BR><BR>This a least might come close to what I think you want to see, right?<BR><BR>You might have a look on<BR><BR>myFFt = fft.fft(inp).real<BR><BR>as well, because it might make things to appear a little clearer.<BR><BR>One more remark: Try to avoid overwriting python key words like 'input'.<BR><BR>Hope this helped.<BR><BR>Cheers<BR>Christian<BR><BR>PS Here is the code
 I used. It looks a bit different from yours - I <BR>hope the comments help a bit:<BR><BR>from numarray import *<BR>import numarray.fft as fft<BR><BR>#at least one of the numbers should be floating point here<BR>period = 1.0<BR>#use numarray's / Numpy's pi instead of 3.14...<BR>inp = sin(arange(0,64)*pi*2/64.0)<BR><BR>myFFT = abs(fft.fft(inp))<BR>#or<BR>#myFFt = fft.fft(inp).real<BR>#or<BR>#myFFT = fft.real_fft(inp)<BR>#depending on what you really want<BR>dtime = period/64.0<BR><BR>dfreq = 1.0/dtime<BR><BR>for i in range(len(myFFT)):<BR>print myFFT[i], dfreq*i<BR><BR><BR></BLOCKQUOTE>