% ---- De Mere's paradox --------
clear;
trials = 10000;
spots11 = 0;
spots12 = 0;
relFreq11 = zeros(1,trials);
relFreq12 = zeros(1,trials);
for n=1:trials
    die1 = fix(6*(rand(1))+1);
    die2 = fix(6*(rand(1))+1);
    die3 = fix(6*(rand(1))+1);
    numSpots = die1+die2+die3;
    if numSpots == 11
        spots11 = spots11 + 1;
    end
    if numSpots == 12
        spots12 = spots12 + 1;
    end
    relFreq11(n) = spots11/n;
    relFreq12(n) = spots12/n;
end

n=1:trials;
figure(1); clf
plot(n,relFreq11, '.')
hold on
plot(n,relFreq12, '.r')
plot(trials,27/216, '*')
plot(trials,25/216, '*r')
hold off
h = legend('11 spots','12 spots',20);
set(h,'Interpreter','none')
ylim([0 0.5])