% File:   dicepair.m
% Author: Michael Goldwasser

% Note: This script assumes that N > 0 is already
% defined as the number of random trials to perform.

% perform random trials
dieA = ceil(rand(1,N)*6);
dieB = ceil(rand(1,N)*6);
pair = dieA + dieB;

% compute and display the histogram of observed data
hist(pair, 2:12);
hold on;

% compute and display the theoretical predictions.
expected = N .* [1:6 5:-1:1] ./ 36;
stem(2:12, expected, 'r');

% Fine-tune the figure style
legend('observed', 'predicted');
title('Histogram of observed rolls for a pair of dice');
axis([0 14 0 N/4]);
grid on;
hold off;
