Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Sounds like a bit more complicated odds-and-evens. Rather than mess with pi and circles, you could just cast 0-9 fingers and get mod 6 + 1.




I think you need 0-5 to avoid bias. (If you are good at generating random 0-9, then you are biasing 0-4 over 5-6, in the mod-6 regime, and I can preserve that bias by preferring to choose small or large numbers depending on whether I want a small or large result)

You must be somewhat right, however only 4 gets biased up:

In [18]: n = 10000000

In [19]: tally = [0,0,0,0,0,0]

In [20]: for i in range(n): ...: tally[(random.randint(0,9)+ random.randint(0,9))%6]+=1 ...:

In [21]: tally Out[21]: [1600008, 1600460, 1699599, 1799697, 1699604, 1600632]




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: