P = [0.02 0.10 0.08; 0.08 0.32 0.40];
x = [1 3]; y = [2 4 5];

pX = sum(P,2)'
pY = sum(P)

EX = x*pX'

VarX = ((x-EX).^2)*pX'

EY = y*pY'

VarY = ((y-EY).^2)*pY'

[X Y] = meshgrid(x,y); X = X'; Y = Y';

PXYl6 = sum(sum([X.*Y<6].*P))

PXeY = sum(sum([X==Y].*P))