Hi! I am using the fft() function the base package to transform some 1d signal. If I use this standar fucntion I get a very huge first fourier coeficient. I think this dues to the handling of the borders of the signal. Usually in fft especially in image processing the signal is simulated to be continuous by adding the signal several times periodically. My question is, is there some function implemented in R handling this or do I have to combine my data manually ? Thanks, -- Frank G. Zoellner AG Angewandte Informatik Technische Fakult"at Universit"at Bielefeld phone: +49(0)521-106-2951 fax: +49(0)521-106-2992 email: fzoellne at techfak.uni-bielefeld.de
>>>>> "Frank" == Frank Gerrit Zoellner <fzoellne at TechFak.Uni-Bielefeld.DE> >>>>> on Thu, 11 Mar 2004 16:04:27 +0100 writes:Frank> Hi! I am using the fft() function the base package Frank> to transform some 1d signal. If I use this standar Frank> fucntion I get a very huge first fourier coeficient. Frank> I think this dues to the handling of the borders of Frank> the signal. Usually in fft especially in image Frank> processing the signal is simulated to be continuous Frank> by adding the signal several times periodically. My Frank> question is, is there some function implemented in R Frank> handling this or do I have to combine my data Frank> manually ? Yes, manually, like fx <- fft(rep(x, 4)) when you want to quadruple your signal. Martin
Frank Gerrit Zoellner wrote:> Hi! > > I am using the fft() function the base package to transform some 1d signal. > If I use this standar fucntion I get a very huge first fourier coeficient. > I think this dues to the handling of the borders of the signal. > Usually in fft especially in image processing the signal is simulated to be continuous by adding the signal several times periodically. My question is, is there some function implemented in R handling this or do I have to combine my data manually ? > > Thanks,The fft function computes the discrete transform d(lambda) = SUM x(t) exp(-i * lambda * t) (for a discrete set of lambda values). The first coefficient is just SUM x(t). This means that the problem is not end-point discontinuity, but the fact that the average level of the signal is non-zero. Replicating the series k times won't help, you'll just make the first coefficent k times bigger. -- Ross Ihaka Email: ihaka at stat.auckland.ac.nz Department of Statistics Phone: (64-9) 373-7599 x 85054 University of Auckland Fax: (64-9) 373-7018 Private Bag 92019, Auckland New Zealand
On Thu, Mar 11, 2004 at 06:14:02PM +0100, Martin Maechler wrote:> > Yes, manually, like > > fx <- fft(rep(x, 4)) >I think rep works on a vector but in my case x is a dataframe/matrix with the signal along the rows. Does rep work on dataframes ? Thanks, -- Frank G. Zoellner AG Angewandte Informatik Technische Fakult"at Universit"at Bielefeld phone: +49(0)521-106-2951 fax: +49(0)521-106-2992 email: fzoellne at techfak.uni-bielefeld.de
On Fri, 12 Mar 2004, Frank Gerrit Zoellner wrote:> On Thu, Mar 11, 2004 at 06:14:02PM +0100, Martin Maechler wrote: > > > > > Yes, manually, like > > > > fx <- fft(rep(x, 4)) > > > > I think rep works on a vector but in my case x is a dataframe/matrix with the signal along the rows. > > Does rep work on dataframes ?Yes, but it does not do what you want I believe. A data frame (sic) is a list, and so the columns are replicated to form a list. Row indexing will work for a data frame or matrix. Say fft(x[rep(1:now(x), 4), ]) ? -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hi, On Thursday 11 March 2004 16:04, Frank Gerrit Zoellner wrote:> I am using the fft() function the base package to transform some 1d signal. > If I use this standar fucntion I get a very huge first fourier coeficient.In electronics, the first coefficient is the dc-component of the signal. If you remove the mean from the signal, the first coefficient should be zero.> I think this dues to the handling of the borders of the signal. > Usually in fft especially in image processing the signal is simulated to be > continuous by adding the signal several times periodically.If you doing a signal analysis of real signals with FFT, you normaly apply a window function to the data (e.g. Hamming window) so the begin and end of the signal is smoothly going down to zero. The reason doing this is that the Fourier transformation "thinks" it analyses a signal with infinit length. So the Fourier transformation "adds" the signal infinitely at the end of the signal. If the start and end of the signal is not the same value, then you have signal with a dis-continuity (the step from the end of the signal to the begin of the "added" signal). which adds a lot of noise in your frequency components. Raphael www.librasch.org