[R] solution of convolution equation

Matthias Kohl Matthias.Kohl at uni-bayreuth.de
Thu Sep 29 22:37:38 CEST 2005

Anna Oganyan wrote:

>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)
>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!
>R-help at stat.math.ethz.ch mailing list
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Hello Anna,

in our R package "distr" (on CRAN) we have implemented a convolution 
algorithm via fft.
See also: 

getMethod("+", signature=c("AbscontDistribution","AbscontDistribution"))

(or see the sources)

Unfortunatelly, we haven't implemented our algorithms for 
multidimensional distributions so far.

hope that helps,

More information about the R-help mailing list