title: convolution in R
body: <p>I tried to do convolution in R directly and using FFTs then taking inverse. But it seems from simple observation it is not correct. Look at this example:</p>
  
  <pre><code># DIRECTLY
  &gt; x2$xt
  [1] 24.610 24.605 24.610 24.605 24.610
  &gt; h2$xt
  [1] 0.003891051 0.003875910 0.003860829 0.003845806 0.003830842
  &gt; convolve(h2$xt,x2$xt)
  [1] 0.4750436 0.4750438 0.4750435 0.4750437 0.4750435
  
  # USING INVERSE FOURIER TRANSFORM
  &gt; f=fft(fft(h2$xt)*fft(x2$xt), inv=TRUE)
  &gt; Re(f)/length(f) 
  [1] 0.4750438 0.4750435 0.4750437 0.4750435 0.4750436
  &gt;
  </code></pre>
  
  <p>Lets take the index 0. At 0, the convolution should simply be the last value of x2$xt (24.610) multiplied by first value of h2$xt (0.003891051) which should give convolution at index 0 = 24.610*0.003891051 = 0.09575877 which is way off from 0.4750436.</p>
  
  <p>Am I doing something wrong? Why is the values so different from expected?</p>