# Convolution of two distribution functions

I have two functions;

f[x_] = (1/k) Exp[-x/k] ;
g[x_] = (1/p) Exp[-x/p] ;


How I can convolve them?

In Mathematica for convolving two functions we have this function:

Convolve[f, g, x, ??]


But I don't know how to do the convolution with the above function for my case.

before I ask this question I searched in detail but I didn't find what I need.

Note: the solution of the above functions is:

(1/k) Exp[-x/k]  *  (1/p) Exp[-x/p]  =  (1/(k-p)) ( Exp[-x/k]  - Exp[-x/p] )


where * is the convolution.

So, how to do this convolution in Mathematica?

• Convolve[f, g, x, y] gives zero (y is the convolution dummy variable) – Nasser Sep 10 '13 at 18:08
• @Nasser You don't happen to have used the OP definitions of the functions? They are not written with the correct Mathematica syntax. Should have been f = (1/k) Exp [-x/k];g = (1/p) Exp [-x/p]; – Sjoerd C. de Vries Sep 10 '13 at 18:38
• You need to use proper Mathematica syntax; the exponential function is Exp[]. Next issue is that the integral will not converge on [-Infinity, Infinity]. – b.gates.you.know.what Sep 10 '13 at 18:38
• @SjoerdC.deVries I just copied what OP wrote and did not even notice the exp vs. Exp ;) , oh boy, now I look at it, I see more syntax errors , using "(" vs. "[" . I need to go make some strong coffee – Nasser Sep 10 '13 at 18:45

The functions do not have a finite area, so they cannot be real distributions as your title claims they are.

Let's change them a bit so they have area 1.

f[x_] = (1/k) Exp[-x/k] UnitStep[x];
g[x_] = (1/p) Exp[-x/p] UnitStep[x];

Integrate[f[x], {x, -∞, ∞}]


ConditionalExpression[1, Re[1/k] > 0]

The convolution:

Convolve[f[x], g[x], x, y] which equals (well apart from the unit step) what you were expecting.

Since your title mentions convolution of distributions let's explore that route as well. A convolution of two probability distributions is defined as the distribution of the sum of two stochastic variables distributed according to those distributions:

PDF[
TransformedDistribution[
x + y,
{
x \[Distributed] ProbabilityDistribution[f[x], {x, -∞, ∞}],
y \[Distributed] ProbabilityDistribution[g[x], {x, -∞, ∞}]
}
],x
] Well, almost. Better to be a bit more complete.

$$\mathrm{E}\mathrm{D}\mathrm{C}\left(b,\beta; t\right)=\mathrm{b}{e}^{-bt} \otimes \beta {e}^{-\beta t} = \left\{\begin{array}{l}\left.\begin{array}{l}\mathrm{b}\beta \frac{e^{-\beta t}-{e}^{-bt}}{\mathrm{b}-\beta },\ \mathrm{b}\ne \beta \\ {}\kern1.75em {\mathrm{b}}^2t\ {e}^{-\mathrm{b}t}\kern0.5em ,\ \mathrm{b}=\beta \end{array}\right\}t\ge 0\\ {}\left.\kern3.75em 0\kern4.1em \right\}t<0\end{array}\right..$$

 Convolve[PDF[ExponentialDistribution[b],z],PDF[ExponentialDistribution[b],z],z,t]

$$\begin{array}{cc} \Big\{ & \begin{array}{cc} b^2 t e^{-b t} & t>0 \\ 0 & \text{True} \\ \end{array} \\ \end{array}$$