Generate a loop vector with certain probability?

1 次查看(过去 30 天)
Hi, I have this loop to generate a matrix of size d with the numbers 1,2,3,4 according to a certain frequency (fn...) and each time one of the elements of the matrix is generated the frequency is recalculated but only after all the numbers generated in each g{x} has been completed. So actually the recalculated frequency is not completely accurate, can be a different way to calculate it not for the whole set but after each number is generated?
d= poissrnd(lambda,1,1000);
for x = 1:numel(d)
tot= q1 + q2 + q3 + q4
f1= q1 / tot
f2= q1 / tot
f3= q1 / tot
f4= q1 / tot
g{x} = randsrc(1,d(x),[1,2,3,4;f1,f2,f3,f4]);
f1 = f1 - (sum(d{x}==1));
f2 = f2 - (sum(d{x}==2));
f3 = f3 - (sum(d{x}==3));
f4 = f4 - (sum(d{x}==4));
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by