필터 지우기
필터 지우기

How to do inverse tranform in dice throw simulate?

조회 수: 4 (최근 30일)
Sherman Ng
Sherman Ng 2022년 4월 2일
댓글: Sherman Ng 2022년 4월 3일
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
Torsten
Torsten 2022년 4월 2일
number_on_dice = find(u<cdf,1,'first');
Does that help ?
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에서 Adding custom doc에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by