Hi dinesh,
Here is an example with two normal (gaussian) pdfs. Arrays x and f(x) describe one of them, and arrays y and g(y) describe the other. To make it general, x and y have different ranges and different number of total points, However, to keep things sensible each of the x and y arrays have the same spacing. The convolution of f and g, called fOg here, is a function fOg(z) of the array z. The key point is that the starting point of the z array is the sum of the starting points of the x and y arrays.
In this example, f(x) peaks at x = 5 and g(y) peaks at y = 9 so you would expect the convolution, which describes the pdf of (x+y), to peak at z = 14 which it does. (Since a gaussian is symmetric about the peak, the peak value and the mean value are the same. And the convolution of gaussians is still a gaussian). If the array limits of x and y are changed, the peak remains at z = 14 (unless the array boundaries start to crowd into the tails of the gaussians and make them not gaussians).
I didn't pay attention to normalization of the pdfs here since the main point is to describe the convolution position. However it should still be true that the integrals described in the last two lines are equal, which they are.
del = .001;
xa = 1;
xb = 7;
nx = (xb-xa)/del;
x = xa + del*(0:nx);
f = exp(-5*(x-5).^2);
ya = 5;
yb = 12;
ny = (yb-ya)/del;
y = ya + del*(0:ny);
g = exp(-4*(y-9).^2);
fOg = conv(f,g)*del;
z = xa+ya+del*(0:nx+ny);
figure(1)
plot(x,f,y,g,z,fOg)
grid on
trapz(x,f)*trapz(y,g)
trapz(z,fOg)
4 Comments
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/609596-x-axis-for-convoluted-function#comment_1048611
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/609596-x-axis-for-convoluted-function#comment_1048611
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/609596-x-axis-for-convoluted-function#comment_1049821
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/609596-x-axis-for-convoluted-function#comment_1049821
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/609596-x-axis-for-convoluted-function#comment_1049831
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/609596-x-axis-for-convoluted-function#comment_1049831
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/609596-x-axis-for-convoluted-function#comment_1050521
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/609596-x-axis-for-convoluted-function#comment_1050521
Sign in to comment.