% Roll2Dice
% Displays the outcomes when a pair of dice is rolled many times

n = 1000000;
% Simulate n dice rolls...
Dice1 = ceil(6*rand(n,1));
Dice2 = ceil(6*rand(n,1));
Pair = Dice1+Dice2;

% Count how many of each outcome...
count = zeros(12,1);
for k=1:n
    i = Pair(k);
    count(i) = count(i)+1;
end

% Display results in Histogram form...
bar(2:12, count(2:12));
title(sprintf('Outcomes from %d rolls of a Pair of Dice', n),'Fontsize',14);
xlabel('Outcome','Fontsize',14);  
ylabel('Number','Fontsize',14);
set(gcf,'Position',[200 200 800 600])
shg
