% 1)
%   a)
%     X = 3 with probability 1/6.
%     Y = 4 with probability 1/6.
%     X and Y are independent => X & Y = 1/6 * 1/6 = 1/36.

%   b)
%     Create a matrix with all X + Y pairs.

XY(1:6, 1:6) = 0;
for i=1:6;
    XY(i, :) = (1:6) + i;
end

% count events that match the condition >=8, and divide
% by total amount of events to obtain the probability.
sum(sum(XY >= 8)) / 36

%   c)
%     First, take only the part of the matrix that matches Y >=4.
XY_Y = XY(1:6, 4:6);

% Again, count acceptable events, and divide by total amount
% of events. Total amount of events is now half of the original
% since possible Y events are are cut down to half.
sum(sum(XY_Y)) / 18


%   d)
%     X:n ehdollinen jakauma ehdolla X + Y = 5.
%     Mahdolliset tapaukset ovat:
%      X=1, Y=4
%      X=2, Y=3
%      X=3, Y=2
%      X=4, Y=1
%      X:n jakauma on siis tasainen jakauma arvojen 1,2,3,4 yli ja 0
%      muualla.
