How to get correct convolution of two random variables (rayleigh distributed)
Show older comments
I want to perform convolution of the density functions of two random variables X and Y (Rayleigh distributed).
X has sigma=0.45, Y has sigma 0.29 using anonymous function and integral expression.
The result fz is exactly equal to fy, I don't know why. How can I get the correct solution of probability density Z= X+Y?
sigma1 = 0.45;
sigma2 = 0.29;
% make sure Rayleigh distribution is => 0.
fx_fun =@(x) [0*x(x<0) , (x(x>=0)./sigma1^2).*exp(-0.5*(x(x>=0)./sigma1).^2)];
fy_fun =@(y) [0*y(y<0) , (y(y>=0)./sigma2^2).*exp(-0.5*(y(y>=0)./sigma2).^2)];
% Rayleigh distribution of random var X,Y:
step = 0.1;
x= -2:step:3; % random variable X - positive only
y= -2:step:3; % random variable Y - positive only
%% Convolution:
z= y;
fz = zeros(size(y));
for i = 1:length(y)
fz(i) = integral(@(z) fy_fun(y(i)).*fx_fun(z-y(i)),0,Inf); % probability density of random variable z= x+y
end
Answers (0)
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!