Hi,
I need to do a convolution between two distributions, such as A and B, to this I have considered using conv. But when the values (x-axis) of the two distributions are different, I have problems interpreting the results. If I convolve A and B, what x-values do I have to plot the results against? Or should I use something other than conv in this case?
For example, which of the dashed curves in this figure is the correct one?
———————————————————————-
clear all; close all; clc
% Distribution A
x_A = [-10:0.5:10]; y_A = normpdf(x_A,2,0.5);
% Distribution B
x_B = [-9:5]; y_B = [0 0 0 0.05 0.1 0.15 0.22 0.31 0.4 0.5 0.7 0 0 0 0];
% Convolution of distributions
conv_AB = conv(y_A,y_B,'same'); conv_BA = conv(y_B,y_A,'same');
figure(1)
plot(x_A,y_A,'k')
hold on
plot(x_B,y_B,'b')
hold on
plot(x_A,conv_AB,':k')
hold on
plot(x_B,conv_BA,':b')
legend('A','B','conv AB – A scale','conv BA – B scale')
———————————————————————-
Best regards, Kristin
Best Answer