Re: [R] Fourier Transform

From: Foadi, J (James) <james.foadi_at_diamond.ac.uk>
Date: Thu, 05 Jun 2008 16:23:09 +0100

-----Original Message-----
From: r-help-bounces_at_r-project.org on behalf of Neil Gupta Sent: Thu 6/5/2008 15:21
To: R-help_at_r-project.org
Subject: [R] Fourier Transform  

Hello All,

I wanted to perform a fourier transform on high frequency financial data. I have searched and have not found much on this topic for R. I was wondering if anyone has used any libraries for it or have come across any papers I may read.

Many Thanks,

Neil Gupta

Dear Neil,
I'm not sure this can be of any help, but here it is anyway.

Given a real function, sample it:



## Sampled density (N points)
sample_rho <- function(rho,N)
{
 xS <- seq(0,1,length=N+1)[1:N]
 yS <- rho(xS)
 xSyS <- list(xS,yS)
 return(xSyS)
}

Then use these sampled values to perform Fourier transform:


xS <- sample_rho(rho,N)[[1]]
yS <- sample_rho(rho,N)[[2]]
F_complex <- fft(yS)/length(yS)

F <- Mod(F_complex)
f <- Arg(F_complex)
F[1] <- Re(F_complex[1])
f[1] <- 0

------------------------------

I have used these and other similar lines when writing an educational paper on Fourier transforms and aliasing:

J. Foadi - "A simple approach to Fourier aliasing" - Eur J Phys 28 (2007) 551-561

My best regards,

James

Dr James Foadi PhD
Membrane Protein Laboratory (MPL)
Diamond Light Source Ltd
Diamond House
Harewell Science and Innovation Campus
Chilton, Didcot
Oxfordshire OX11 0DE

Email : james.foadi_at_diamond.ac.uk
Alt Email: j.foadi_at_imperial.ac.uk
<DIV><FONT size="1" color="gray">This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail. Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message. Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom </FONT></DIV>



R-help_at_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. Received on Thu 05 Jun 2008 - 17:36:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 Jun 2008 - 18:30:40 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive