[R] Fast fourier transformation
Hi, here is a practical problem we would like to solve. In a pneumatic post the acceleration of the capsule is measured and plotted over time. From the graph achieved we would like to derive some kind of statistic value that describes the stress the capsule, or what is in it, is exhibited to. The amount of stress introduced to the capsule will probably depend on two things, the maximum amplitudes observed AND the frequency of these amplitudes. A quick note at this point: Not the acceleration by itself but the quick acceleration changes are the components which make up the special stress we want to quantify. So what I would like to do is: 1) Apply a fourier transformation to the acceleration profile to 2) get a number of harmonic waves describing my graph 3) and use the amplitudes of my waves in a weighted fashion to calculate some statistical value. What I tried to do is: A) construct an artificial profile fg for testing purpose like a. f1 - function(x) 0.5*sin(3*x + pi) b. f2 - function(x) sin(x + 0.75*pi) c. f3 - function(x) 1.5*sin(0.45*x + 0*pi) d. fg - function(x) f1(x) + f2(x) + f3(x) B) try to reconstruct the components of fg with fft or fda. What I don't understand yet is how: X) in my test example I can define the amount of harmonic components, because here I know that number. Of course afterwards in my natural profiles I won't know. Y) I have to transform the values I get out of the fft and fourier functions to estimate the frequency, amplitude and phase of my harmonics. Is there a good function in these packages I can use for that? Best regards, Benjamin -- Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universitätsklinikum Hamburg-Eppendorf Körperschaft des öffentlichen Rechts Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender) Dr. Alexander Kirstein Ricarda Klein Prof. Dr. Dr. Uwe Koch-Gromus [[alternative HTML version deleted]] __ 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.
Re: [R] Fast fourier transformation
botto b.otto at uke.uni-hamburg.de writes: here is a practical problem we would like to solve. In a pneumatic post the acceleration of the capsule is measured and plotted over time. From the graph achieved we would like to derive some kind of statistic value that describes the stress the capsule, or what is in it, is exhibited to. .. 1) Apply a fourier transformation to the acceleration profile to 2) get a number of harmonic waves describing my graph 3) and use the amplitudes of my waves in a weighted fashion to calculate some statistical value. What I tried to do is: A) construct an artificial profile fg for testing purpose like a. f1 - function(x) 0.5*sin(3*x + pi) X) in my test example I can define the amount of harmonic components, because here I know that number. Of course afterwards in my natural profiles I won't know. Y) I have to transform the values I get out of the fft and fourier functions to estimate the frequency, amplitude and phase of my harmonics. Check function spectrum in stats which also has some methods to provide smoothed plots. There is also package signal which I have not tried. And don't expect too much of phase plots, I have seen generations of students jumping on these to explain the universum, the EEG and US politics because it sound so mysterious, and never seen a working method coming out of it. It would have been good if you had provided a real example series because then it would have been possible to tell you if you could find a reasonable estimate of the true frequency and acceleration. In general, when you have only very few oscillations, you get a seemingly lousy estimate, which is only the consequence of how fft is defined as a rather broad-minded model. If you are sure that there is a single frequency with harmonics, other methods such as cyclic gams or even cyclic nlme (see the oestrus example in that package) might provide better results. Dieter __ 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.
Re: [R] Fast fourier transformation
A powerful scheme for harmonic inversion of time signals known as filter diagonalization method is available from MIT: http://ab-initio.mit.edu/wiki/index.php/Harminv I don't know of any R interface, but it might be a good option for your problem. Cheers, baptiste On 10 Feb 2009, at 13:40, Dieter Menne wrote: botto b.otto at uke.uni-hamburg.de writes: here is a practical problem we would like to solve. In a pneumatic post the acceleration of the capsule is measured and plotted over time. From the graph achieved we would like to derive some kind of statistic value that describes the stress the capsule, or what is in it, is exhibited to. .. 1) Apply a fourier transformation to the acceleration profile to 2) get a number of harmonic waves describing my graph 3) and use the amplitudes of my waves in a weighted fashion to calculate some statistical value. What I tried to do is: A) construct an artificial profile fg for testing purpose like a. f1 - function(x) 0.5*sin(3*x + pi) X) in my test example I can define the amount of harmonic components, because here I know that number. Of course afterwards in my natural profiles I won't know. Y) I have to transform the values I get out of the fft and fourier functions to estimate the frequency, amplitude and phase of my harmonics. Check function spectrum in stats which also has some methods to provide smoothed plots. There is also package signal which I have not tried. And don't expect too much of phase plots, I have seen generations of students jumping on these to explain the universum, the EEG and US politics because it sound so mysterious, and never seen a working method coming out of it. It would have been good if you had provided a real example series because then it would have been possible to tell you if you could find a reasonable estimate of the true frequency and acceleration. In general, when you have only very few oscillations, you get a seemingly lousy estimate, which is only the consequence of how fft is defined as a rather broad-minded model. If you are sure that there is a single frequency with harmonics, other methods such as cyclic gams or even cyclic nlme (see the oestrus example in that package) might provide better results. Dieter __ 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. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ 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.