How to generate the convolution density and integrate it on [a,b] fastly and precisely?

7 views (last 30 days)
Hi, I have two random variables X following distribution F with density f, and Y following distribution G with density g
random variable Z=X+Y, and I want to calculate the probability that Z belongs to interval [a,b].
I guess this could be done by first get the density of Z as the convolution of f and g, and then do numerical integration to this convolution density over [a,b]. How to do this in a fast and precise way? Thanks!

Accepted Answer

Jeff Miller
Jeff Miller on 22 Aug 2020
If your random variables X and Y are independent, Cupid might be helpful. It defines a general convolution RV for any continuous independent RVs. If your distributions are already defined in cupid, the code would look something like:
X = Exponential(1/10); % Illustration with example distributions
Y = Beta(5,2.3);
Z = Convolution(X,Y);
a = 2;
b = 4;
probInterval = Z.CDF(b) - Z.CDF(a);
If either/both of your distributions are not already in Cupid, it is pretty easy to add new distributions if you have the formula for either the PDF or the CDF.
Whether this will be fast and accurate enough for you, I cannot say.

More Answers (1)

Mahesh Taparia
Mahesh Taparia on 22 Aug 2020
Hi
You can use 'conv' function to perform the convolution of the CDF and 'integral' function to perform integration. For more information, refer to the documentation of conv function and integral function.
Hope it will help!
  2 Comments
Walter Roberson
Walter Roberson on 22 Aug 2020
You cannot use conv() to do the convolution of a distribution. conv() is only for discrete convolution.
You can use the formal definition of convolution as an integral, which might require the symbolic toolbox.
Alternatively you could potentially use the property that convolution of two functions is the inverse fourier of the multiplication of the fourier transform. This would not be fft, this would be fourier() from the symbolic toolbox.
You can also do something similar with laplace transform.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!