convolve(x, y, conj = TRUE)
x,y
| numeric sequences of the same length to be convolved. |
r <- convolve(x,y) and n <- length(x), then
r[k] = sum(i=1,..,n; x[i] * y[k-i])
for k = 1,...,n, where y[j] == y[n+j] for j < 0.
The Fast Fourier Transform, fft, is used for efficiency.
fft, nextn.x <- c(0,0,0,100,0,0,0) y <- c(0,0,1, 2 ,1,0,0)/4 round(convolve(x,y), 7)# this is *NOT* what you first thought.. x <- rnorm(50);y <- rnorm(50) all(convolve(x,y), convolve(y,x)) all(convolve(x,y, conj = FALSE), rev(convolve(y,x)))