Hacker News new | ask | show | jobs
by aidenn0 42 days ago
This is also an easy way to detect RNGs that are not truncated (i.e. return the entire state (or any 1-to-1 permutation of their entire state):

https://www.pcg-random.org/posts/birthday-test.html

Example:

Any RNG with a period 2**32 that can output every 32-bit value at least once must have zero collisions for the first 2**32 outputs, but we would expect to see about 100 collisions after just 200k outputs.

1 comments

Such an RNG would be great for playing your 2^32 song collection, since you'd never hear the same song twice within a given time through.
There are a lot more straightforward implementations of "shuffle this list of things" than "craft an RNG that doesn't repeat so that your can get the index of each song one at a time".

I've never understood why so many people like to cite that as an example of "not wanting true randomness", when it seems like people do want true randomness, just as an ordered set rather than "pick a random song from scratch each time".