[R] convolve bug?

Bill Simpson wsi at gcal.ac.uk
Fri Nov 19 18:58:52 CET 1999


> 
> Bill, I can assure you that statisticians use 'convolution' in 
> the same way as engineers do. It is actually the defaults in
> R that are rather nonstandard (and the help is wrong).
Thanks Yudi for clearing this up! I'm glad that it is only R that is wrong
and not statisticians as a race :-)

> I agree with Bill that convolve() should mean convolution 
> operation. So the default 'conj' should be set to F (Fourier
> transform of a convolution is a product of the transfroms), 
> and the zero padding is on the right. 
> 
> E.g., target:  (2,2,3,3,4)*(1,1,2)  =  (2  4  9 10 13 10  8 )
> 
> convolve(c(2,2,3,3,4),c(2,1,1),type='o')
> #[1]  2  4  9 10 13 10  8  
> convolve(c(2,2,3,3,4),c(1,1,2),conj=F,type='o')
> #[1] 10  8  2  4  9 10 13      # almost 
>  x _ c(2,2,3,3,4,0,0)   # zero padding
> y _ c(1,1,2,0,0,0,0)
> aa_ fft(fft(x) * fft(y), inv = TRUE)
> Re(aa)/length(aa)
> #[1]  2  4  9 10 13 10  8   # wanted
> 
> I would suggest that the 'conj' option not be provided;
> when conj=F, the type='f' option gives meaningless answer:
I agree!!
Instead, if you want to cross-correlate two functions, use a separate R
function called correlate or crosscorrelate() that is almost the same as
convolve() except it does complex conjugate of one of the FFTed functions
before multiplying them

Bill

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list