Re: [R] Weird (wrong?) result for fft

2021-03-22 Thread Jiefei Wang
Hi Filippo, Why do you expect these two expressions to produce the same output? Especially the second expression contains the first expression. There is no way to have the same result unless the function "fft( * , inverse = TRUE)" does nothing but multiplies the input by the input's length. It

Re: [R] Weird (wrong?) result for fft

2021-03-22 Thread Jeff Newmiller
Neither. The discrete Fourier transform is a complex number operation. R-help is per the Posting Guide not an appropriate place to discuss theory in depth, and there is plenty of theory in this question and practically no R, but you can examine your result more closely with the functions

[R] Weird (wrong?) result for fft

2021-03-22 Thread Filippo Monari
Hi all, I am plying around with fft function from the stats package. Running the example that is listed in the documentation: x <- 1:4 fft(x) #output 1 fft(fft(x), inverse = TRUE)/length(x) #output 2 I was expecting that output 1 and two were the same but I get: > fft(x) [1] 10+0i -2+2i -2+0i