% L6B demo % Sum of three dice -- exact distribution % % Returns: % p Probabilities of values 1...18 % function p = L6Bthreedice_exact p = zeros(1,18); % Consider all possible triples (x,y,z). % Each of them contributes exactly 1/216 to the probability % of sum s=x+y+z. for x=1:6 for y=1:6 for z=1:6 s = x+y+z; p(s) = p(s) + 1/216; end end end end