Live data from Hacker News

Evolution of Random Number Generators

johndcook.com

51–56 of 56 posts

Re: Evolution of Random Number Generators

#51
post #49
post #36

Earlier quoted context omitted.

Fisher-Yates is one of the simplest things out there IMO. Isn't the Lehmer code the thing that you want? Then you can specify your permutation with an integer and extract the individual digits from it repeatedly.

Fisher-Yates is one of the simplest things out there IMO Just using "$n xor $something" would be simpler. I am just not sure yet, what a good "$something" is.

How does this guarantee the desired property of the output being a permutation?

Re: Evolution of Random Number Generators

#52
post #35
post #34

Earlier quoted context omitted.

Wouldn't a SIMDified implementation of other RNGs speed them up by a comparable factor, making MT relatively slower again?

If the next number depends on the previous number (like with wyrand and many others) it can't be simdified. You could simdify computation with different seeds tho, which might be fine for many purposes. However at that point it's also a custom implementation with a different number sequence than the non-simd version, which isn't the case with a SIMDified MT.

Also xoshiro generators are enough cheaper than MT that even if you couldn't simdify it, you could keep 4 and get run the 4 together in SIMD to get 4 outputs way cheaper than 1 SIMD MT.

Re: Evolution of Random Number Generators

#53
I'm reminded of Chris Wellon's "Prospecting for Hash Functions", where he randomly generates hash functions and then runs them through a couple of tests.

https://nullprogram.com/blog/2018/07/31/

Out of curiosity, is running the state through a hash a reasonable rand strategy?

Re: Evolution of Random Number Generators

#54
post #50
post #30

Earlier quoted context omitted.

Xoring won’t work: - xoring will only produce permutations that have period two, and every element will be part of a 2-cycle. - if your n isn’t a power of two, it may produce numbers larger than n The set of 2-cycles will have a lot of structure, too (for example, if your magic constant is even, all cycles will have either two even numbers or two odd numbers; if it is odd, all cycles will have an even and an odd numb…

if your n isn’t a power of two, it may produce numbers larger than n This is the biggest problem. The others are not such big problems as I don't need strong resemblence to real randomness.

I can’t look into your use case, but I’m not sure you realize how spectacularly bad xoring with a fixed value is as a way to generate a ‘random’ permutation.

For example, it will still alternate odd and even numbers.

Also, an adversary can derive the xor key from a single sample, and predict the entire sequence from it.

Re: Evolution of Random Number Generators

#55
The PCG author (Melissa O'Neill of Harvey Mudd) has an interesting story of how PCG and its paper came about https://www.pcg-random.org/posts/history-of-the-pcg-paper.ht... Good to read in case you think that academic peer review is the only way to introduce new and useful methods to the world.

Re: Evolution of Random Number Generators

#56
post #54
post #50

Earlier quoted context omitted.

if your n isn’t a power of two, it may produce numbers larger than n This is the biggest problem. The others are not such big problems as I don't need strong resemblence to real randomness.

I can’t look into your use case, but I’m not sure you realize how spectacularly bad xoring with a fixed value is as a way to generate a ‘random’ permutation. For example, it will still alternate odd and even numbers. Also, an adversary can derive the xor key from a single sample, and predict the entire sequence from it.

Alterning odd and even numbers is fine.

There is no adversary. The use case is not about security.

Post reply on HN