統計学入門

4.6ガリレイの問題

p9 = []
p10 = [] 
for x in range(1,6+1):
    for y in range(1,6+1):
        for z in range(1,6+1):
            if (x + y + z) == 9:
                p9.append((x,y,z))
            if (x + y + z) == 10:
                p10.append((x,y,z))
print("p9= ",len(p9))
for p in p9:
    print(p)
print("p10= ",len(p10))
for p in p10:
    print(p)
<結果>
和が9になる組み合わせが25組、和が10に成る組み合わせ27組
したがって同じではない.
p9=  25
(1, 2, 6)
(1, 3, 5)
(1, 4, 4)
(1, 5, 3)
(1, 6, 2)
(2, 1, 6)
(2, 2, 5)
(2, 3, 4)
(2, 4, 3)
(2, 5, 2)
(2, 6, 1)
(3, 1, 5)
(3, 2, 4)
(3, 3, 3)
(3, 4, 2)
(3, 5, 1)
(4, 1, 4)
(4, 2, 3)
(4, 3, 2)
(4, 4, 1)
(5, 1, 3)
(5, 2, 2)
(5, 3, 1)
(6, 1, 2)
(6, 2, 1)
p10=  27
(1, 3, 6)
(1, 4, 5)
(1, 5, 4)
(1, 6, 3)
(2, 2, 6)
(2, 3, 5)
(2, 4, 4)
(2, 5, 3)
(2, 6, 2)
(3, 1, 6)
(3, 2, 5)
(3, 3, 4)
(3, 4, 3)
(3, 5, 2)
(3, 6, 1)
(4, 1, 5)
(4, 2, 4)
(4, 3, 3)
(4, 4, 2)
(4, 5, 1)
(5, 1, 4)
(5, 2, 3)
(5, 3, 2)
(5, 4, 1)
(6, 1, 3)
(6, 2, 2)
(6, 3, 1)