필터 지우기
필터 지우기

Dice Probability on Matlab...so lost!!

조회 수: 2 (최근 30일)
Matthew
Matthew 2012년 11월 21일
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

답변 (1개)

Image Analyst
Image Analyst 2012년 11월 21일
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.

카테고리

Help CenterFile Exchange에서 Strategy & Logic에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by