% EQUALBARS % % Approximate, by simulation, the probability of obtaining % six equal bars (heights 2,2,2,2,2,2) when rolling 12 dice. tic n = 100000; u = 0; for i=1:n % One experiment of rolling 12 dice. Count each value. barheights = hist(dice(12),1:6); % Did we get all bars equal? if all(barheights==2) u = u+1; end end toc u/n