% function outcome = coinflips(N)
%
% Input: 
%  N = number of times to flip the coin
%
% Output:
%  outcome = array with structure
%    [# heads flipped, # tails flipped]
%
function outcome = coinflips(N)

% Get N random numbers in (0,2)
x = 2*rand(1,N);

% Initialize heads and tails counters to zero
Hcount = 0;
Tcount = 0;

% For each random number, decide if it is a head or tail
for i = 1:N
    if ( floor(x(1,i))==0 )
        Hcount = Hcount + 1;
    else
        Tcount = Tcount + 1;
    end
end

% Record outcome
outcome = [Hcount Tcount];