# [Numpy-discussion] Here's what I've done to numpy.fft

David Goldsmith d.l.goldsmith@gmail....
Mon Jul 12 22:41:45 CDT 2010

2010/7/12 Jochen Schröder <cycomanic@gmail.com>

> On 13/07/10 08:47, David Goldsmith wrote:
> > In light of my various questions and the responses thereto, here's what
> > I've done (but not yet committed) to numpy.fft.
> >
> > There are many ways to define the DFT, varying in the sign of the
> > exponent, normalization, etc.  In this implementation, the DFT is defined
> > as
> >
> > .. math::
> >     A_k =  \sum_{m=0}^{n-1} a_m \exp\left\{-2\pi i{mk \over n}\right\}
> >     \qquad k = 0,\ldots,n-1
> >
> > where n is the number of input points.  In general, the DFT is defined
> > for complex inputs and outputs, and a single-frequency component at
> linear
> > frequency :math:f is represented by a complex exponential
> > :math:a_m = \exp\{2\pi i\,f m\Delta t\}, where
> > :math:\Delta t is the *sampling interval*.
> >
> > Note that, due to the periodicity of the exponential function, formally
> > :math:A_{n-1} = A_{-1}, A_{n-2} = A_{-2}, etc.  That said, the values
> in
> > the result are in the so-called "standard" order: if A = fft(a,n),
> > then A[0] contains the zero-frequency term (the sum of the data),
> > which is always purely real for real inputs.  Then A[1:n/2] contains
> > the positive-frequency terms, and A[n/2+1:] contains the
> > negative-frequency (in the sense described above) terms, from least (most
> > negative) to largest (closest to zero).  In particular, for n even,
> > A[n/2] represents both the positive and the negative Nyquist
> > frequencies, and is also purely real for real input.  For n odd,
> > A[(n-1)/2] contains the largest positive frequency, while
> > A[(n+1)/2] contains the largest (in absolute value) negative
> > frequency.  In both cases, i.e., n even or odd, A[n-1] contains the
> > negative frequency closest to zero.
> >
> > Feedback welcome.
> >
> > DG
> >
> Hi David,
>
> great work. I agree with Travis leave the sampling out. This make things
> more confusing. I'd also suggest pointing to fftshift for converting the
> "standard" order to order "min frequency to max frequency"
>

Thanks, Jochen.  Such a pointer was/is already in the original docstring; I
found nothing unclear about it, so I didn't modify it, so I didn't include
it in my post; indeed, the complete docstring is much longer - I only posted
that portion to which I made significant changes.  (To which I should
probably add: I haven't "picked over" the rest of the docstring w/ nearly
the same degree of care as that portion I did post, primarily because my
main motivation in doing what I did was for consistency w/ what I'm
"borrowing" from the docstring for the much more succinct narrative portion
I'm adding to the docstring for scipy.fftpack.basic.  In other words, though
numpy.fft's docstring was at "Needs review" status going into this, it
should probably be put back to "Being written.")

DG

>
> Cheers
> Jochen
> >
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion@scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>

--
Mathematician: noun, someone who disavows certainty when their uncertainty
set is non-empty, even if that set has measure zero.

Hope: noun, that delusive spirit which escaped Pandora's jar and, with her
lies, prevents mankind from committing a general suicide.  (As interpreted
by Robert Graves)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100712/22bc02c5/attachment.html