Dice Probability on Matlab...so lost!!
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Yatzi is a game played by rolling 5 dice. My function Yatzi simulates the rolling of 5 dice. The function should take one input, N umR olls, the total number of times that the 5 dice will be rolled. The function should have four outputs which give, in order, the relative frequencies (probabilities) of following scenarios:
The 5 dice showing number 1, 2, 3, 4, and 5 two, and only two, dice showing number 2 at least two dice showing number 4 all 5 dice showing identical number This is what I have so far, but I have no idea how to proceed. help please!
function = Yatzi (NumRolls)
roll(rerolls) = randi(6,[5 length(rerolls)]);
if( result(1) == result(2) &&
result(2) == result(3) &&
result(3) == result(4) &&
result(4) == result(5) )
end
0 Kommentare
Antworten (1)
Image Analyst
am 21 Nov. 2012
Did you see my advice to your classmate: http://www.mathworks.com/matlabcentral/answers/54410#answer_66109 You have to get the histogram, then divide by the number of counts in the histogram. For the second scenario, what values of the sum will you have if all 5 dice have the same value: 1, 2, 3, 4, 5, or 6? Think about it. What's the sum if all 5 dice are = 1? Then you just have to read off those 5 numbers from the histogram.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Strategy & Logic 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!