3 ms·
It all comes down to generating deterministic permutations instead of purely random numbers, since the intent is to avoid bad luck. The most common permutation
by ryacko 7y ago
It all comes down to generating deterministic permutations instead of purely random numbers, since the intent is to avoid bad luck.
The most common permutation used is the AES S-Box, commonly available through various ISA extensions. There are many ways to generate permutations though, and it wouldn’t require a large complex algorithm to avoid a 1 in 10 chance event happening three times in a row or generating the entire permutation to be stored in memory.
- HelloNurse 7y agoS-boxes compute fixed permutations of the bits in a small fixed length buffer, which is entirely inappropriate for accurately picking random permutations of a variable and usually large number of choices.
- ryacko 7y agoFor a RNG, the maximum run length of same values would be the period length divided by the output size (in general). The blog post is horrifying, it feeds the output of the Mersenne Twister into another function to reduce the run length of seemingly biased outcomes. I think to generate a single value the whole CPU’s cache is cleared from the size and complexity of the code. The AES S-box, with the seed XORed before and after, would still be a better solution (especially since the probably of certain runs of similar values should be somewhat low). The theory behind LCGs is a lot simpler, and using a suitably small prime, I think, one could have an appropriately short period without excessive predictability.