renata.camargo05 at ntlworld.com
2008-Jul-30 11:14 UTC
[R] FFT - (STATS) - is this correct?
Hello,
I have calculated the fourier transform of the series enclosed at the end of
this message, by doing:
library(stats)
x <- readLines("file1.txt")
x.num <- as.numeric(x)
ft.x.num <- fft(x.num)
My question is: why is the first value (Real) of ft.x.num that big? (954.833870)
all the other values are much smaller. Am I doing something wrong?
Could you please help me to understand that?
Many thanks, Renata
2.24791
6.39824
7.43533
7.21367
11.2164
7.29183
9.72807
12.8445
12.4819
8.18952
6.38345
9.98463
6.25724
7.97327
8.9676
8.27709
14.8272
13.4908
11.876
11.4889
11.3161
9.79778
8.09873
4.43935
5.30657
9.37819
0
8.09507
10.9567
10.5478
12.6661
13.8612
14.025
13.9403
11.5847
9.50861
7.81196
5.42222
5.27313
4.16159
3.83932
8.95892
11.9548
12.7598
11.6816
13.3388
13.1956
9.50887
12.4671
11.2608
12.6553
5.63253
4.18556
4.47097
9.13142
5.29101
11.3582
7.5489
13.0371
9.26487
11.6458
6.26179
10.4051
11.7282
9.36171
10.7723
4.90151
4.25747
6.95437
6.17832
11.59
13.894
10.8935
8.19078
6.27219
6.74875
10.076
6.47078
11.1408
6.48286
10.4232
9.23548
11.199
7.97828
13.1261
12.1624
7.90476
11.7495
14.0312
9.97212
11.3685
12.6093
4.68484
4.72131
5.10963
8.1693
8.21239
10.6743
5.39084
11.1944
12.4415
8.0419
5.62567
12.2756
0
-----------------------------------------
Email sent from www.virginmedia.com/email
Virus-checked using McAfee(R) Software and scanned for spam
#ts with a freq=1 d <- ts(x) #it seems that this is an oscillating signal of ~ a day plot(d) #spectrogram which shows that the main frequency component is ~ 0.7. this translates to about a day (1.3 or so) sec.pgram(d) On Wed, Jul 30, 2008 at 7:14 AM, <renata.camargo05@ntlworld.com> wrote:> Hello, > > I have calculated the fourier transform of the series enclosed at the end > of this message, by doing: > > library(stats) > x <- readLines("file1.txt") > x.num <- as.numeric(x) > ft.x.num <- fft(x.num) > > My question is: why is the first value (Real) of ft.x.num that big? > (954.833870) all the other values are much smaller. Am I doing something > wrong? > > Could you please help me to understand that? > > Many thanks, Renata > > 2.24791 > 6.39824 > 7.43533 > 7.21367 > 11.2164 > 7.29183 > 9.72807 > 12.8445 > 12.4819 > 8.18952 > 6.38345 > 9.98463 > 6.25724 > 7.97327 > 8.9676 > 8.27709 > 14.8272 > 13.4908 > 11.876 > 11.4889 > 11.3161 > 9.79778 > 8.09873 > 4.43935 > 5.30657 > 9.37819 > 0 > 8.09507 > 10.9567 > 10.5478 > 12.6661 > 13.8612 > 14.025 > 13.9403 > 11.5847 > 9.50861 > 7.81196 > 5.42222 > 5.27313 > 4.16159 > 3.83932 > 8.95892 > 11.9548 > 12.7598 > 11.6816 > 13.3388 > 13.1956 > 9.50887 > 12.4671 > 11.2608 > 12.6553 > 5.63253 > 4.18556 > 4.47097 > 9.13142 > 5.29101 > 11.3582 > 7.5489 > 13.0371 > 9.26487 > 11.6458 > 6.26179 > 10.4051 > 11.7282 > 9.36171 > 10.7723 > 4.90151 > 4.25747 > 6.95437 > 6.17832 > 11.59 > 13.894 > 10.8935 > 8.19078 > 6.27219 > 6.74875 > 10.076 > 6.47078 > 11.1408 > 6.48286 > 10.4232 > 9.23548 > 11.199 > 7.97828 > 13.1261 > 12.1624 > 7.90476 > 11.7495 > 14.0312 > 9.97212 > 11.3685 > 12.6093 > 4.68484 > 4.72131 > 5.10963 > 8.1693 > 8.21239 > 10.6743 > 5.39084 > 11.1944 > 12.4415 > 8.0419 > 5.62567 > 12.2756 > 0 > > > ----------------------------------------- > Email sent from www.virginmedia.com/email > Virus-checked <http://www.virginmedia.com/emailVirus-checked> using > McAfee(R) Software and scanned for spam > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- 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 [[alternative HTML version deleted]]
On 30/07/2008, at 11:14 PM, <renata.camargo05 at ntlworld.com> wrote:> Hello, > > I have calculated the fourier transform of the series enclosed at > the end of this message, by doing: > > library(stats) > x <- readLines("file1.txt") > x.num <- as.numeric(x) > ft.x.num <- fft(x.num) > > My question is: why is the first value (Real) of ft.x.num that big? > (954.833870) all the other values are much smaller. Am I doing > something wrong? > > Could you please help me to understand that?Just look at the definition of the discrete Fourier transform: n X(omega) = SUM x_t * exp(i*omega*t) t=1 (The mailer will probably mess up that expression and put everything out of alignment; if only these <expletive deleted> mailers would leave well enough alone and simply transmit plain ascii files and display the results in a fixed width font ..... Anyway, I hope you can read it.) The point is that the fast Fourier transform calculates the discrete Fourier transform at each of the ``Fourier'' frequencies omega_j = 2*pi*j/n, j = 0, ..., n-1. The result is, as you noted in your follow-up email ``palindromic'' --- X(omega_{n- j}) = X(omega_j)^* where ``*'' indicates complex conjugate. At omega_0 = 0 you obviously get X(omega_0) = sum(x) --- that's where the value 954.833870 comes from. Just execute sum(x) to check this. If you want to understand the discrete Fourier transform, I suggest you read Peter Bloomfield's book ``Fourier Analysis of Time Series --- An Introduction'' (2nd ed.), Wiley Series in Probability and Statistics, 2000. cheers, Rolf Turner P.S. BTW doing ``library(stats)'' is silly; the stats library is loaded automatically when R is started. R. T. ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}