[R] fft(x, inv=TRUE)

Ben Bolker ben at zoo.ufl.edu
Thu Jan 9 03:23:03 CET 2003


  I would guess that the imaginary parts are very small -- essentially 
numeric error.  I sometimes use the following function to get rid of these 
tiny, spurious imaginary parts.

chop <- function (x, fuzz = 1e-10) 
{
    if (is.numeric(x)) {
        x
    }
    else if (is.complex(x)) {
        ifelse(abs(Im(x)) < fuzz, Re(x), x)
    }
}


On Wed, 8 Jan 2003 PLauren at genelogic.com wrote:

> I started out with a real vector b and then obtained its Fourier transform
> thus
> B<-fft(b)
> When I did
> F<-fft(B, inv=TRUE)
> I expected that F would be the inverse FT of B but it still has imaginary
> components.
> 
> Should the inverse FT not be purely real? Am I missing something?
> 
> Thanks,
> Peter.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 

-- 
318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704




More information about the R-help mailing list