Joaquin Rapela
2013-Apr-19 21:36 UTC
[R] How to select the scale parameter for Gabor transform (Rwave)?
Dear list, I am trying to choose the scale parameter for the cgt transform but I don't know how to do it. In time I would like to be able to separate points 30 samples apart, and in frequency I would like to separate bands 0.04 Hz apart. I tried the two approaches described below and they gave me different results. I would appreciate advise on how to do this. The Rwave Gabor transform uses a Gaussian window; i.e., g(x)=exp(-x^2/(2*sigma)), with radius deltaG=sqrt(sigma/2). The Fourier transform of this window has a radius deltaGHat=1/sqrt(2*sigma). Solving for deltaG=10 I get sigma=200, which in turn gives deltaGHat=0.05 radians=0.008 Hz. So, sigma=200 should satisfy the requirements above. To make sure sigma=200 works in practice, I computed the Gabor transform of two sinusoids separated by 0.04 Hz plus two spikes separated by 30 points using the code below. I obtained an excellent frequency resolution but a disastrous temporal resolution http://sccn.ucsd.edu/~rapela/scaleSelectionProblem/gtResultSigma200.jpg. To obtain decent frequency and temporal resolutions I used sigma=10 http://sccn.ucsd.edu/~rapela/scaleSelectionProblem/gtResultSigma10.jpg. fromTime <- 0 toTime <- 250 by <- 1 ts <- seq(from=fromTime, to=toTime) f1 <- 0.01 f2 <- 0.05 t1 <- 50 t2 <- 80 K <- 15 fMax <- 0.20 nf <- 100 df <- fMax/(nf/2) scale <- 10 ys <- sin(2*pi*f1*ts) + sin(2*pi*f2*ts) ys[t1] <- K ys[t2] <- K plot(x=ts, y=ys, xlab="Time", ylab="Signal", type="b") cgtsinwave <- cgt(input=ys, nvoice=nf, freqstep=df, scale=scale, plot=TRUE) Many thanks, Joaquin -- Joaquin Rapela, PhD Swartz Center for Computational Neuroscience University of California San Diego 9500 Gilman Drive, San Diego, CA 92093-0559 tel: (858) 822-7536 fax: (858) 822-7556 http://sccn.ucsd.edu/~rapela
Joaquin Rapela
2013-Apr-20 03:25 UTC
[R] How to select the scale parameter for Gabor transform (Rwave)?
Dear list, It seems that there is a typo in the book "Practical Time-Frequency Analysis" that documents Rwave. The window that the cgt function of Rwave seems to be using g(x)=exp(-x^2/(2*sigma^2)) and not g(x)=exp(-x^2/(2*sigma)) as stated in Equation (3.23) of the book. Also, it appears that the scale parameter in the cgt of Rwave equals sigma. In the previous email I derived an optimal sigma=200, and if in the code below I use sigma=sqrt(200), I obtain a Gabor transform with good time-frequency resolution. I am copying the authors of Rwave in this message. If the previous observation is correct, it would be a good idea to discuss it in the documentation of Rwave. Cordially, Joaquin scale On Fri, Apr 19, 2013 at 02:36:56PM -0700, Joaquin Rapela wrote:> > Dear list, > > I am trying to choose the scale parameter for the cgt transform but I don't > know how to do it. In time I would like to be able to separate points 30 > samples apart, and in frequency I would like to separate bands 0.04 Hz > apart. I tried the two approaches described below and they gave me > different results. I would appreciate advise on how to do this. > > The Rwave Gabor transform uses a Gaussian window; i.e., > g(x)=exp(-x^2/(2*sigma)), with radius deltaG=sqrt(sigma/2). The Fourier > transform of this window has a radius deltaGHat=1/sqrt(2*sigma). Solving > for deltaG=10 I get sigma=200, which in turn gives > deltaGHat=0.05 radians=0.008 Hz. So, sigma=200 should satisfy the > requirements above. > > To make sure sigma=200 works in practice, I computed the Gabor transform of > two sinusoids separated by 0.04 Hz plus two spikes separated by 30 points > using the code below. I obtained an excellent frequency resolution but a > disastrous temporal resolution > http://sccn.ucsd.edu/~rapela/scaleSelectionProblem/gtResultSigma200.jpg. To > obtain decent frequency and temporal resolutions I used sigma=10 > http://sccn.ucsd.edu/~rapela/scaleSelectionProblem/gtResultSigma10.jpg. > > fromTime <- 0 > toTime <- 250 > by <- 1 > ts <- seq(from=fromTime, to=toTime) > f1 <- 0.01 > f2 <- 0.05 > t1 <- 50 > t2 <- 80 > K <- 15 > fMax <- 0.20 > nf <- 100 > df <- fMax/(nf/2) > scale <- 10 > > ys <- sin(2*pi*f1*ts) + sin(2*pi*f2*ts) > ys[t1] <- K > ys[t2] <- K > > plot(x=ts, y=ys, xlab="Time", ylab="Signal", type="b") > cgtsinwave <- cgt(input=ys, nvoice=nf, freqstep=df, scale=scale, plot=TRUE) > > Many thanks, Joaquin > > -- > Joaquin Rapela, PhD > Swartz Center for Computational Neuroscience > University of California San Diego > 9500 Gilman Drive, > San Diego, CA 92093-0559 > tel: (858) 822-7536 > fax: (858) 822-7556 > http://sccn.ucsd.edu/~rapela > > ______________________________________________ > 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.-- Joaquin Rapela, PhD Swartz Center for Computational Neuroscience University of California San Diego 9500 Gilman Drive, San Diego, CA 92093-0559 tel: (858) 822-7536 fax: (858) 822-7556 http://sccn.ucsd.edu/~rapela ---------------------------------- Elle [Il dispendieux] suppose une volont? de mouvement, un consentement aux flux et aux fleuves. D'o? l'h?raclit?isme du dispendieux que veut et aime la mobilit?, que sollicite la circulation dans le dessein de produire des opportunit?s pour une plus grande probabilit? de d?penses. Il n'ignore pas l'inscription de son existence dans une perspective dialectique. Au-del? de l'ontologie ou de la m?taphysique, il sait n'avoir pour seul capital que sa vie, qu'elle ne durera pas ?ternellement, que d?j? elle es compt?e, d?s ? pr?sent limit?e. Et, for de ce savoir, il a d'autant d'enthousiasme qu'il appr?cie l'extr?me valeur de ce que ne dure pas. La mort donne le prix, elle fixe le sens. Michel Onfray La sculpture de soi: la morale esth?tique [El dispendioso] Supone una voluntad de movimiento, un consentimiento a flujos y r?os. De ah?, el heraclite?smo del dispendioso que desea y al que le gusta la movilidad, que solicita la circulaci?n con el objeto de producir oportunidades para una mayor probabilidad de gasto. No ignora que su vida se inscribe en una perspectiva dial?ctica. M?s all? de la ontolog?a o de la metaf?sica, sabe que que su ?nico capital es su vida y que ?sta no durar? enternamente, que ya tiene los d?as contados, que est? limitada en ese momento. Y, sabiendo eso, su entusiasmo es directamente proporcional a su aprecio por el extremo valor de lo que no dura. La muerte pone el precio, fija el sentido. Michele Onfray La Escultura de S?: por una moral est?tica