[R] Convolution confusion:

From: Alex Hofmann <ahah_at_gmx.net>
Date: Wed, 18 May 2011 15:47:16 +0200


Hi,

I'm new to R, and I'm a bit confused with the "convolve()" function. If I do:
x<-c(1, 2, 3)
convolve(x, rev(x), TRUE, "open")
= 9 12 10 4 1

But I expected: 3 8 14 8 3 (like in Octave/MATLAB - conv(x, reverse(x)) )

3 2 1 x 1 2 3
= 3 2 1

     0 6 4 2
     0 0 9 6 3

= 3 8 14 8 3

The thing is, that "convolve(x, x, TRUE, "open")" works. For me it feels very confusing, that convolution does the reverse itself but the help suggest to reverse it again.

The help file says: "Note that the usual definition of convolution of two sequences x and y is given by convolve(x, rev(y), type = "o")."

Thanks for your help,

Alex



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. Received on Wed 18 May 2011 - 15:06:57 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 27 May 2011 - 22:40:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive