What to do with for-while loop?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
The question is "Create the matrix based on the probabilities [0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125] until you get the 1st 8 "
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?
2 Kommentare
Torsten
am 3 Apr. 2022
u = rand()
gives you only one random number.
So over what do you sum in the next line of your code ?
Antworten (1)
Torsten
am 3 Apr. 2022
number_on_dice = 6;
bu = [ ];
while number_on_dice ~= 8
u = rand();
number_on_dice = sum(cdf <= u) + 1;
bu = [bu;[u,number_on_dice]];
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!