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

One important catch, however, is using a proper (P)RNG. Not all of them stay perfectly uniform if you scale and round them over all ranges of 2..n.

Since you usually get a stream of random bits, afaik the only fair way is to mask bits to get a uniform number 0 <= R < the next power of two. Then toss the result and reroll if it's outside the desired range.



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

Search: