function count = rollUnfairDie(rolls)
% Simulate rolling of unfair 6-sided die
% Usage: count = rollUnfairDie(rolls)
% ROLLS is the number of times to roll die
% COUNT is vector of number of times each outcome occurs

FACES= 6; % number of FACES on die
count= zeros(1,FACES); % bins to store frequencies

% Roll UNFAIR die
allRolls= round(rand(1,rolls)*FACES);
% Discard zeros
allRolls= allRolls(allRolls>0);

% Count outcomes
for i= 1:length(allRolls)
count(allRolls(i))= count(allRolls(i)) + 1;
end

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