I want to calculate/evaluate the convolution
$$g(x)=\int_D f(x-t) \phi(t) dt,$$
where $f$ is a density and $\phi$ is a smooth function with compact support $D$. The convolution is not available in closed-form and I need to integrate it numerically. My question is: Is there an efficient way to do this? I want to implement it in R, so, I would like to see if there is a better way than using the command integrate()
.
?fft
) or useconvolve
. The fft approach takes a bit more work to set up but is better if you need to convolve with something several times. Sometimes it takes a while to figure out the right argument settings with convolve. $\endgroup$convolve
for this purpose several times. Simple working examples appear at stats.stackexchange.com/a/41263, stats.stackexchange.com/a/41255, and stats.stackexchange.com/a/49444. $\endgroup$