% Rolling a die
% Simulation of events: 3 dots show (probability of 1/6),
% at least 3 dots show (4/6), and less than 3 dots show.
%
  disp('Rolling a Die in MATLAB')
  lw = 2; 
  set(0, 'DefaultAxesFontSize', 16);
  fs = 15;
  rand('twister',20)
  msize = 10;
% end of preabmle-------------------------------------
close all
outcomes = []; %keep outcomes here
M=50000 %rolls
for i= 1:M
outcomes = [outcomes ceil( 6*rand )];
%ceil(6*rand) rounds up (ceiling) random
%number uniform on (0,6), thus the outcomes 
% 1,2,3,4,5,and 6  are equally likely
end
probA = sum((outcomes == 3))/M
   % probA = 0.1628
probB = sum((outcomes >= 3))/M
   % probB = 0.6669
 probC = sum((outcomes < 3))/M
   % probC = 0.3331
 % ---------------------
 % Figure----------------------------------------------
plot( (1:100),outcomes(1:100), 'k-')
hold on
plot( (1:100),outcomes(1:100), 'o',...
                'MarkerEdgeColor','k',...
                'MarkerFaceColor','g',...
                'MarkerSize',12)
xlabel('Trial Number')
ylabel('Outcome')
set(gca,'Ytick',[1, 2, 3, 4, 5, 6], 'YTickLabel',{'One';'Two';'Three';'Four';'Five';'Six'})
% print -depsc  'C:\Springer\Probs\Probseps\rolldie.eps'

