[Numpy-discussion] FFT definition

Timothy Hochberg tim.hochberg at ieee.org
Mon Feb 5 12:09:04 EST 2007


On 2/5/07, Hanno Klemm <klemm at phys.ethz.ch> wrote:
[numpy.fft[

    The packing of the result is "standard": If A = fft(a, n), then A[0]
>     contains the zero-frequency term, A[1:n/2+1] contains the
>     positive-frequency terms, and A[n/2+1:] contains the
> negative-frequency
>     terms, in order of decreasingly negative frequency. So for an 8-point
>     transform, the frequencies of the result are [ 0, 1, 2, 3, 4, -3,
> -2, -1].


[scipy.fft]


      f = [0,1,...,n/2-1,-n/2,...,-1]/(d*n)         if n is even
>       f = [0,1,...,(n-1)/2,-(n-1)/2,...,-1]/(d*n)   if n is odd
>
> >>>
>
> So one claims, that the packing goes from [0,1,...,n/2,-n/2+1,..,-1]
> (fft) and the other one claims the frequencies go from
> [0,1,...,n/2-1,-n/2,...-1]
>
> Is this inconsistent or am I missing something here?


Both, I think.

In the even case, the frequency at n/2 is shared by both the positive
frequencies, so for that case things are consistent if not terribly clear.
For the odd case, this is not true, and the scipy docs look correct in this
case, while the numpy docs appear to assign an extra frequency to the
positive branch. Of course that's not the one you were complaining about
;-).

To be super pedantic, the discrete Fourier transform is periodic, so all of
the frequencies can be regarded as positive or negative. That's not
generally useful, since the assumptions that go into the DFT that make it
periodic don't usually apply to the signal that you are sampling. Then again
the results of DFTs are typicallly either small or silly in the vicinity of
N//2.


//=][=\\

tim.hochberg at ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070205/01cc0e33/attachment.html>


More information about the NumPy-Discussion mailing list