[R] Is R's fast fourier transform function different from "fft2" in Matlab?

stephen sefick ssefick at gmail.com
Fri Aug 1 16:24:51 CEST 2008


Yep you are totally right.  I looked at the graphs to do the analysis
quickly, and sacrificed correctness.
z <- rnorm(5000)
z.ts <- ts(z)
f <- fft(z.ts)
d <- fft(f, inverse=T)
plot(z.ts, d/5000)

#this is how far off the algorithm was from recreating the series.
After it is divided by the signal length.
plot((z.ts)-(d/5000))

Does this hold for longer signals, too?

On Thu, Jul 31, 2008 at 11:30 PM, Rolf Turner <r.turner at auckland.ac.nz> wrote:
>
> On 1/08/2008, at 2:56 PM, stephen sefick wrote:
>
>>  z <- rnorm(5000)
>>  f <- fft(z)
>>  d <- fft(f, inverse=T)
>> plot(z, d)
>>
>> z <- rnorm(5000)
>> z.ts <- ts(z)
>> f <- fft(z.ts)
>> d <- fft(f, inverse=T)
>> plot(z.ts, d)
>>
>> temp  <- matrix(c(1,4,2, 20), nrow=2)
>> d <- fft(temp)
>> f <- fft(d, inverse=T)
>> plot(temp, f)
>>
>> this, looks to me, to be the same.
>
>        Then I think you'd better get your eyes checked, mate!
>
>> you have to take the inverse of the fft to get the original series.
>
>        No you ***don't*** get the original series; you get n*(the original
> series)
>        where n is the series length.
>
>        I.e. the fft in R (and in S/Splus) does not apply any normalizing
> factor,
>        so that the inverse transform only ``inverts'' up to a constant
> multiple.
>
>                cheers,
>
>                        Rolf Turner
>
> ######################################################################
> Attention:This e-mail message is privileged and confidential. If you are not
> theintended recipient please delete the message and notify the sender.Any
> views or opinions presented are solely those of the author.
>
> This e-mail has been scanned and cleared by
> MailMarshalwww.marshalsoftware.com
> ######################################################################
>



-- 
Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

	-K. Mullis



More information about the R-help mailing list