Skip to main content
added 180 characters in body
Source Link
Tel
  • 11
  • 2

You are doing a convolution operation. The implementation in R uses FFT internally and you are unlikely to beat it with loops and such things.

> convolve(x=cvals=c(4, 5, 7, 3, 9, 8, 0)
> convolve(x=vals, y=c(1, 1, 1)/3, type="filter")
[1] 5.33 5.00 6.33 6.67 5.67

If you want to extract every second result.

> tmp <- convolve(x=vals, y=c(1, 1, 1)/3, type="filter")
> tmp[0:2*2+1]
[1] 5.33 6.33 5.67

You are doing a convolution operation. The implementation in R uses FFT internally and you are unlikely to beat it with loops and such things.

> convolve(x=c(4, 5, 7, 3, 9, 8), y=c(1, 1, 1)/3, type="filter")
[1] 5.33 5.00 6.33 6.67

You are doing a convolution operation. The implementation in R uses FFT internally and you are unlikely to beat it with loops and such things.

> vals=c(4, 5, 7, 3, 9, 8, 0)
> convolve(x=vals, y=c(1, 1, 1)/3, type="filter")
[1] 5.33 5.00 6.33 6.67 5.67

If you want to extract every second result.

> tmp <- convolve(x=vals, y=c(1, 1, 1)/3, type="filter")
> tmp[0:2*2+1]
[1] 5.33 6.33 5.67
Source Link
Tel
  • 11
  • 2

You are doing a convolution operation. The implementation in R uses FFT internally and you are unlikely to beat it with loops and such things.

> convolve(x=c(4, 5, 7, 3, 9, 8), y=c(1, 1, 1)/3, type="filter")
[1] 5.33 5.00 6.33 6.67