Fast Fourier Transform

DESCRIPTION:

Performs the fast Fourier transform on a vector or an array of either numeric or complex values.

USAGE:

fft(z, inverse=F) 

REQUIRED ARGUMENTS:

z
numeric or complex vector or array.

OPTIONAL ARGUMENTS:

inverse
logical flag: if TRUE, the inverse of the transform is computed.

VALUE:

the unnormalized discrete Fourier transform of the input data z, or the inverse transform if inverse=TRUE. This is of mode "complex". Because the unnormalized transform is computed, the commands fft(fft(z), inverse=T) and fft(fft(z, inverse=T)) return nz for an n-dimensional vector z. If you require Fourier coefficients, you should divide the value that fft returns by the length of the input vector.

DETAILS:

The fast Fourier transform algorithm is used. No padding of the input data is done; length(z) is factored, if possible, and the factorization is used in the algorithm. Therefore, if length(z) is prime, there will be no advantage in using fft over computing the transform explicitly.

If z is an array, fft will return the multi-dimensional unnormalized discrete Fourier transform of z-a complex array with the same shape as z. Therefore, using fft on a multivariate time series will not compute the time transform.

The discrete Fourier transform is used to compute an approximation to the continuous Fourier transform of a periodic function F. In the usual definition, n points are sampled from F symmetrically around 0; that is, the domain of the sampled points is [-N/2,N/2], where N is the period of F. However, S-PLUS assumes the n points are sampled from the interval [0,N]. When this convention is followed, the resulting frequencies are shifted. For example, let j be the index of the sampled points and suppose n is even. In S-PLUS, the zero frequency corresponds to j=1, the positive frequencies correspond to 2 <= j <= n/2, the negative frequencies correspond to n/2+2 <= j <= n, and the Nyquist critical frequency corresponds to j = n/2+1. The definitions are analagous if n is odd. For more details, see Press et al. (1996).

REFERENCES:

Bloomfield, P. (1976). Fourier Analysis of Time Series: An Introduction. Wiley, New York.

The chapter "Analyzing Time Series" in the S-PLUS Guide to Statistical and Mathematical Analysis.

Press, W.H., Teukolsky, S.A., Vetterling, W.T., & Flannery, B.P. (1996). Numerical Recipes in Fortran 77: The Art of Scientific Computing (2nd ed.). New York: Cambridge University Press.

SEE ALSO:

.