Chosing the correct x scale after convolution

12 views (last 30 days)
Sven
Sven on 3 Dec 2014
Answered: Achim Göritz on 15 Dec 2014
Hi there,
I am trying to solve a, in principle, very simple statistical problem with the conv function in Matlab. Unfortunately, I do not really understand the outcome of the calculations.The model that is used describes the probability of observing a single event with energy E that is
u=1/(a*T)*exp(-E/(a*T)).
The parameter a is fixed and can for demonstration purposes set to 1. E is the variable and T is the temperature. However, not the probability of a single event but the combined probability of several are of interest. For example the probability for two consequtive events is just the convolution of the probabilities of the two single events. The various events can have different temperatures lets say T1,T2,... and hence I will label the functions u1,u2,.. (but they will all have the same energy scale E). In Matlab I simply wrote the code
E=0:0.01:10; % set energy scale
T=[520 480 441 402 364 325 287 249 211 175 138]; % set temperatures
for i=1:size(T,2)
u(i,:)=1./T(i).*exp(-E./T(i)); % calculate all possible distribution functions
end
w(1,:)=conv(u(1,:),u(2,:),'full'); % First combined probability
The generalization to all other terms should be easy. However, if I use the 'full' option I get the expected result but with 2*length(E)-1 datapoints in w. This is clear insofar that this is how the convolution works in Matlab. But how can I link the combined probability to the SAME energy scale I used to define the seperate distribution functions?
More confusing is the result when I use the 'same' option of conv. Then the number of data points of w is identical to u1 and u2 but the result looks completly different. Usually I did convolutions analytically and not numerically and maybe I do not get the difference here. Therefore, any advice concerning this problem is highly appreciated.
Best
Sven

Answers (3)

Image Analyst
Image Analyst on 4 Dec 2014
Sven, they're the same. The "same" is just cropped from the interior of the "full" like you expect. Look
E=0:0.01:10; % set energy scale
T=[520 480 441 402 364 325 287 249 211 175 138]; % set temperatures
for i=1:size(T,2)
u(i,:)=1./T(i).*exp(-E./T(i)); % calculate all possible distribution functions
end
wFull = conv(u(1,:),u(2,:),'full'); % First combined probability
wSame = conv(u(1,:),u(2,:),'same'); % First combined probability
plot(wFull, 'b-', 'LineWidth', 2);
hold on;
plot(wSame, 'r-', 'LineWidth', 2);
grid on;
legend('Full', 'Same');

Sven
Sven on 4 Dec 2014
Hi Image Analyst,
that's what I figured first and your results makes complete sense. Now I tried it myself and I can understand the result with a=1 (I should have tested a=1 first). Unfortunately, this confuses me even more. For example if you try a=2.15e-4. For this case I get the following results
I have scaled the x axis to the region of interest. The function should look like the 'full' result because the more of the probability functions you convolute the the more the maximum must shift to bigger x values and approaches a Gaussian function shape eventually. This does not happen for the 'same' result, though (even by scaling the y axis). The 'same' result is just a simple exp(-x) function. So either I can understand why for this particular case 'same' and 'full' are so different or can scale the x-axis of the 'full' result accordingly.

Achim Göritz
Achim Göritz on 15 Dec 2014
Hi everyone,
I give it a last chance. Does someone know what causes these dramatic changes between the 'same' and the 'full' method? It seems very strange to me that the outcome of the function depends on the choice of the numbers.
Any hints or tips are highly appriciated.
Best
Sven

Categories

Find more on Creating and Concatenating Matrices 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!