function count = rollDie (nRolls)
% Simulate rolling of a fair 6-sided die.
% Returns 6-vector showing how many times each outcome has occurred

count= zeros(1,6);                  % Bins to store counts
rolls = ceil(6 * rand(1, nRolls));  % Compute all rolls

% Count outcomes
for k= 1:6
    count(k) = sum(rolls == k);
end

% Show histogram of outcome
bar(1:6, count);
title(['Outcomes from ' num2str(nRolls) ' rolls of fair die']);
xlabel('Outcome');  ylabel('Count');

