[Numpy-discussion] FFT definition
Timothy Hochberg
tim.hochberg@ieee....
Mon Feb 5 12:13:29 CST 2007
On 2/5/07, Warren Focke <focke@slac.stanford.edu> wrote:
>
>
>
> 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)
Ooops, you're right I worked this through on paper and just blew it. I
suppose I'd look less silly had I actually checked the results using the
interpreter.
--
//=][=\\
tim.hochberg@ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070205/a9e1e709/attachment.html
More information about the Numpy-discussion
mailing list