Recursion to compute convolution
이전 댓글 표시
Hello,
consider the sum of i.i.d. random variables
with
:
Is it possible to implement this recursively?
If it is, can anybody tell me how I can do that or give at least a hint?
댓글 수: 4
Image Analyst
2020년 11월 15일
If you want convolution, simply use the built-inconv() function. Don't do it manually - the hard way.
Alex Schmdit
2020년 11월 15일
Image Analyst
2020년 11월 15일
I don't know what that formula is, especially the index for P which is S(n-1)==(k - j), but I'm just going by what you say - that you want convolution. There is a built in function for that, that takes several arguments. First one is the main signal. Second argument is the filter weights of the scanning/sliding filter window. Third argument is whether you want the full convolution, only the valid elements, or an output that is the same size as the input signal. Look up the documentation and online tutorials about what convolution is. Find one that has diagrams that show the window as it slides along -- I'm sure there are lots of convolution tutorials out there.
Alex Schmdit
2020년 11월 15일
편집: Alex Schmdit
2020년 11월 15일
채택된 답변
추가 답변 (2개)
Image Analyst
2020년 11월 15일
If dist is your distribution, then the distribution of the sum would be
distSum = conv(dist, dist, 'full');
No recursion needed.
댓글 수: 3
Alex Schmdit
2020년 11월 15일
Image Analyst
2020년 11월 15일
That is your probability distribution function for your random variable. Just one, not the distribution of the sum of the two but just one alone. For example for a uniform distribution it would be all ones, like
n = 500; % Whatever.
dist = ones(n, 1) / n;
subplot(2, 1, 1);
plot(dist, 'b-', 'LineWidth', 2);
title('PDF (Histogram) of One Variable', 'FontSize', 15);
ylim([0, 0.0025]);
grid on;
distSum = conv(dist, dist, 'full');
subplot(2, 1, 2);
plot(distSum, 'b-', 'LineWidth', 2);
grid on;
title('PDF (Histogram) of Sum of Two Variables', 'FontSize', 15);
where n is the resolution you want to digitize your continuous PDF at.

Image Analyst
2020년 11월 15일
Looks like you've accepted Bruno's answer, so I guess you got it all solved now.
Let the vector M be the distribution of integer valued X. For example, if X takes on values 1-6 uniformly, then
M = ones(1,6)/6;
Now you can compute the distribution of the sum of the random sample of X as:
Mn = M;
for ii = 2:n
Mn = conv(Mn,M);
end
This isn't recursive, so I'm not sure if that's the implementation you want. Also, it may not be efficient depending on the values of numel(M) and n because Mn is growing each time through the loop. But I think it gives you the result you seek. You'll have to be careful the indexing of Mn if X can take on values less than 1.
댓글 수: 1
카테고리
도움말 센터 및 File Exchange에서 F Distribution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!