How to do inverse tranform in dice throw simulate?

2 次查看(过去 30 天)
Hi so I'm trying to simulated loaded dice throw and do a inverse transform, here's my code so far:
a = [0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125];
cdf = cumsum(a);
u = rand(); % assume u = 0.5
b = sum(cdf <= u) + 1
What should I do next for the inverse transform, and do I need a for loop?
  2 个评论
Sherman Ng
Sherman Ng 2022-4-3
So apparently the question is only asking for the u's and b's so I do not have to compute the list of s. Apparently I need a for-while-loop to fill in values of u and b. How should I do the for-while loop though?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by