[R] convolve bug?
yudi@ucd.ie
yudi at ucd.ie
Fri Nov 19 16:09:17 CET 1999
I'm not sure if the group gets this.
> Date: Fri, 19 Nov 1999 10:09:17 +0000 (GMT)
> From: Bill Simpson <wsi at gcal.ac.uk>
> BTW I don't see why you say it is OK to define convolution with no
> reversal of the function! If you don't reverse, the operation is
> CORRELATION. Or do statisticians make no distinction between convolution
> and correlation? Anyway I like the definition of convolution given on the
> help page. (Even though it is not what is happening)
>
> This is really sad that the engineers and stats types have such totally
> different conventions.
>
> To me, the linear system output y(t) is the convolution of the input x(t)
> and the impulse response h(t):
> y(t) = x(t) * h(t)
> where * is convolution.
> But this means something completely different to a
> statistician, who in my language would interpret this as "linear
> system output y(t) is the correlation of the input x(t) and the impulse
> response h(t)", which is wrong.
>
> The convolution and correlation theorems are also screwed up (the complex
> conjugation).
>
> I'm glad I know about this sad state of affairs now! The help page refs
> Brillinger, a stats type (though I know he has published papers in IEEE
> journals, so he must constantly have to be flipping things in his head!).
> I will look at his book.
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).
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:
convolve(c(2,2,3,3,4),c(1,1,2),conj=F,type='f')
#[1] 2 4 9
-Yudi-
------------------------------
Yudi Pawitan: yudi at stat.ucc.ie
Department of Statistics, UCC
Cork, Ireland
Ph : 353-21-902 906
Fax: 353-21-271 040
------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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