[R] solution of convolution equation

Anna Oganyan aoganyan at niss.org
Thu Sep 29 21:22:51 CEST 2005

```Hello,
May be somebody can help me...
I am trying to find a solution of a convolution equation using fft (and
unfortunately I do not have a good background for this).
So I am just trying to figure out how it can be implemented in R. I have
two multidimensional independent variables X and Z
and I know their densities fx and fz, which are multidimensional arrays.
So I have to find the density of Y, such that X+Y=Z.
So, first I tried on a simple example, where the variables are
one-dimensional, say X is N(0,1) and Z is N(7,3).
So I want to find the density of Y (which should be N(7, sqrt(8)).
I did:
x <- seq(-6, 20, length=500)
fx <- dnorm(x)
z <- seq(-6, 20, length=500)
fz <- dnorm(z, mean=7, sd=3)
ffty <- fft(fz)/fft(fx)
fy <- fft(ffty, inverse=T)/length(ffty)
plot(Re(fy))

But the plot is far from being normal. May be the problem is with the
lengths of fx and fz? should they be of different lengths and fx padded
with zeros? May be somebody could point out that…? Thanks!
Anna

```