[Numpy-discussion] FFT definition
Warren Focke
focke@slac.stanford....
Mon Feb 5 11:53:04 CST 2007
On Mon, 5 Feb 2007, Timothy Hochberg wrote:
> On 2/5/07, Hanno Klemm <klemm@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
> ;-).
Extra frequency where?
(numpy 1.0, debian sarge)
>>> n=9
>>> A=arange(n)
numpy docs:
>>> A[1:n/2+1]
array([1, 2, 3, 4])
>>> A[n/2+1:]
array([5, 6, 7, 8])
scipy docs:
>>> (n-1)/2
4
>>> -(n-1)/2
-4
Note that in the odd-n case, there is no Nyquist term. If
F = fft(f), len(f) == 9
then F[-4] != F[4] (F[5] == F[-4] by periodicty in frequency)
w
>
> 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@ieee.org
>
More information about the Numpy-discussion
mailing list