【发布时间】:2013-11-14 15:49:35
【问题描述】:
我正在做涉及太多 for 循环的计算。我将不胜感激任何可以消除一些循环以使算法更有效的想法。这是我想要得到的数学表达式:随机变量 Y 的离散分布。
Pr(Y=y)=
∑_Pr(Z=z) ∙∑_Pr((X=x) ∑_Pr(W=w) ∙∑_Pr(R=r│W=w) ∙Pr(S=z+y-x-r|W=w)
Y,Z,X,W,R,S 是离散随机变量,它们是相关的。我知道每个术语的表达式,但只有概率计算,而不是近似分布。
array Y[max_Y+1]; % store the distribution of Y
temp1=0, temp2=0, temp3=0, temp4=0; % summation for partial distributions
for y = 0 max_Y
temp1=0;
for z = 0 : 5- y
temp2=0;
for x=0:5
temp3=0;
for w=0:5
temp4=0
for r=0:w
temp4=temp4+Pr(R=r│W=w)∙Pr(S=z+y-x-r|W=w);
end
temp3=temp3+temp4*Pr(W=w);
end
temp2= temp2+temp3*Pr(X=x);
end
temp1=temp1+temp2* P(Z=z);
end
Y[y]=temp1;
end
非常感谢! 酯类
【问题讨论】:
-
我看不懂它的写法。修改或转储。
标签: algorithm for-loop probability performance