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!