3 ms·
experimental evidence says that it is in fact a uniform distribution: r = random.Random() def one_to_five(): return r.randint(1, 5) def mod_seven()
by llimllib 18y ago
experimental evidence says that it is in fact a uniform distribution:
r = random.Random()
def one_to_five():
return r.randint(1, 5)
def mod_seven():
return (sum(one_to_five() for x in xrange(7)) % 7) + 1
def test_dist(lst):
return [(x, lst.count(x)) for x in [1,2,3,4,5,6,7]]
- sdfx 18y agoi've tried it out experimentally in google docs and it looks really good for big numbers. No real proof tho and it might be that the errors counter each other by chance: http://spreadsheets.google.com/ccc?key=pq4tB7LQWN03gF7ImGhIPAw http://spreadsheets.google.com/ccc?key=pq4tB7LQWN03gF7ImGhIP...
- greendestiny 18y agoHave a look at the distributions for each sum here: http://brianpmearns.com/ext/dice/dice.html http://brianpmearns.com/ext/dice/dice.html edit: Oops bad addition on my part, could be uniform, but you'd have to work out the actual number exactly.
- sdfx 18y agohere are the exact numbers: 1 -> 11177 2 -> 11172 3 -> 11158 4 -> 11144 5 -> 11144 6 -> 11158 7 -> 11172 ...not quite
- gaius 18y agoI've done a lot of Python but never knew about xrange - thanks!