% L3B empirical study % If we roll a fair die 12 times, how often does it happen % that every result (1,2,3,4,5,6) appears exactly two times? function L3Bdicestats(rep) if nargin<1, rep=1e3; end tic cpu0 = cputime; nsuccess = 0; for i=1:rep emp = hist(dice(12), 1:6); if all(emp == 2) nsuccess = nsuccess + 1; end if mod(i,10000)==0 fprintf('%d trials in %.2f s...\n', i, cputime-cpu0); end end toc fprintf('%10d trials (of rolling a die 12 times)\n', rep); fprintf('%10d successes (all bars height 2)\n', nsuccess); fprintf('%10.5f success rate\n', nsuccess/rep); end