% Class 4 start exercise % End of day example - game of Yahtzee ngames = 10000; ThrowVec = zeros(ngames,1); for i = 1:ngames; count = 0; YC = 0; while YC < 5 DV = randi(6,5,1); CV = DV == DV(1,1); YC = sum(CV); count = count + 1; %{ if YC == 5 disp('YAHTZEE! YOU WIN') else disp('Try again.') end %} end ThrowVec(i,1) = count; end AvgThrow = mean(ThrowVec) % From probability we know P = (1/6)^4; AvgNumTimes = 1/P