Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
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.gatessucks 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

1 Answer 1

up vote 8 down vote accepted

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] 

Mathematica graphics

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
]

Mathematica graphics

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.