Skip to content

convolve bug?

1 message · yudi@ucd.ie

#
Note this one:
 x<-c(2,2,3,3,4)
 h<-c(2,1,1)   # reverse the filter
 convolve(x,h,type="o")
[1]  2  4  9 10 13 10  8     # matches Bracewell
The filter in R is not reversed, which is fine as long as it is
understood so, but the help is not consistent:

            For `open' and `filter', the sequences are padded
             with `0's (from left and right) first; `"filter"'
             returns a the middle sub-vector of `"open"',
             namely, the result of running a weighted mean of
             `x' with weights `y'.

This implies y is not reversed, but the definition

           r[k] = sum(i=1,..,n;  x[i] * y[k-i])

reverses y, which is not the way it is implemented.

-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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._