nblances = 300;
de1 = int(rand(1, nblances)*5 + 1);
de2 = int(rand(1, nblances)*6 + 1);

histplot([.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5], de1);
xset("window", 1);
histplot([.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5], de2);

tirages = int(rand(100, nblances)*6 + 1);
for i = 1:6, totaux(:, i) = sum(bool2s(tirages == i),'c'), end;

distfreq = totaux/nblances - 1/6;
distfreqcarre = distfreq .* distfreq;

d2exp = sum(distfreqcarre, 'c');
histplot(20, d2exp);

trie = sort(d2exp);
d9 = trie(10);

for i = 1:6, total1(i) = sum(bool2s(de1 == i)), end;

distfreq1 = total1/nblances - 1/6;
distfreqcarre1 = distfreq1 .* distfreq1;

d2exp1 = sum(distfreqcarre1);

for i = 1:6, total2(i) = sum(bool2s(de2 == i)), end;

distfreq2 = total2/nblances - 1/6;
distfreqcarre2 = distfreq2 .* distfreq2;

d2exp2 = sum(distfreqcarre2);

p = 1/6;
ecartTypeCarre = p*(1-p)/nblances
d9math = cdfchi("X", 5, .9, .1)
6/5*d9math*ecartTypeCarre/d9
