Live data from Hacker News

PCG, A Family of Better Random Number Generators

pcg-random.org

21–30 of 57 posts

Re: PCG, A Family of Better Random Number Generators

#22
post #7

This is fine for quickly generating random numbers for simulations, just don't use it for cryptographic applications. If you want random numbers for crypto use a CSPRNG.

For non-crypto applications it is really good. Very fast and simple.

Re: PCG, A Family of Better Random Number Generators

#23

Earlier quoted context omitted.

Just as you wouldn't want to use a general purpose PRNG for security applications so too you wouldn't want to use a secure PRNG for general purposes, particularly demanding applications such as Monte Carlo simulations. Your dismissal strikes me as both ignorant and rude.

> Just as you wouldn't want to use a general purpose PRNG for security applications so too you wouldn't want to use a secure PRNG for general purposes, particularly demanding applications such as Monte Carlo simulations. Why not? It's perfectly valid to use a secure RNG for non-secure purposes. As I mentioned, I've used ChaCha20 for those sort of purposes too. And the random number generation barely shows up as a fra…

The reason why is crypto RNG are much slower than something less secure. It really depends on the application, but in the code I wrote today a significant fraction of my application’s time was spent in the RNG function. By replacing the RNG I managed to speed up my code by a bit over 2 fold. I am not doing crypto work so this is great.

Re: PCG, A Family of Better Random Number Generators

#24

Earlier quoted context omitted.

Just as you wouldn't want to use a general purpose PRNG for security applications so too you wouldn't want to use a secure PRNG for general purposes, particularly demanding applications such as Monte Carlo simulations. Your dismissal strikes me as both ignorant and rude.

> Just as you wouldn't want to use a general purpose PRNG for security applications so too you wouldn't want to use a secure PRNG for general purposes, particularly demanding applications such as Monte Carlo simulations. Why not? It's perfectly valid to use a secure RNG for non-secure purposes. As I mentioned, I've used ChaCha20 for those sort of purposes too. And the random number generation barely shows up as a fra…

> Why not? It's perfectly valid to use a secure RNG for non-secure purposes.

It's much slower. Yes, in your application it was a fraction, but they are still much slower than non-secure RNG's.

Re: PCG, A Family of Better Random Number Generators

#26

Earlier quoted context omitted.

Just as you wouldn't want to use a general purpose PRNG for security applications so too you wouldn't want to use a secure PRNG for general purposes, particularly demanding applications such as Monte Carlo simulations. Your dismissal strikes me as both ignorant and rude.

> Just as you wouldn't want to use a general purpose PRNG for security applications so too you wouldn't want to use a secure PRNG for general purposes, particularly demanding applications such as Monte Carlo simulations. Why not? It's perfectly valid to use a secure RNG for non-secure purposes. As I mentioned, I've used ChaCha20 for those sort of purposes too. And the random number generation barely shows up as a fra…

One of the benefits of a PRNG is reproducibility. If you are doing a monte carlo simulation, then you can get good results while still starting runs from predictable seeds. (e.g. [0,1,2,3,4,...])

This gives you both good quality random numbers during the simulation run yet lets others reproduce your results and expand with more results if required.

Re: PCG, A Family of Better Random Number Generators

#27
post #26

Earlier quoted context omitted.

> Just as you wouldn't want to use a general purpose PRNG for security applications so too you wouldn't want to use a secure PRNG for general purposes, particularly demanding applications such as Monte Carlo simulations. Why not? It's perfectly valid to use a secure RNG for non-secure purposes. As I mentioned, I've used ChaCha20 for those sort of purposes too. And the random number generation barely shows up as a fra…

One of the benefits of a PRNG is reproducibility. If you are doing a monte carlo simulation, then you can get good results while still starting runs from predictable seeds. (e.g. [0,1,2,3,4,...]) This gives you both good quality random numbers during the simulation run yet lets others reproduce your results and expand with more results if required.

ChaCha20 is a cipher, of course, it creates reproducible sequences.

Re: PCG, A Family of Better Random Number Generators

#28
post #5

There is a seminar about PCG from its author available on youtube. https://www.youtube.com/watch?v=45Oet5qjlms Its a bit long but I highly recommend it. I learned a lot about RNGs from it.

Speaker mentions[0] that it is possible to get a different statistically random value every time you run the program, without any input to the program, apparently by using some tricks, but she refuses to elaborate for the camera. Can anyone explain how that works?

Has this something to do with address space randomization?

[0]:https://youtu.be/45Oet5qjlms?t=1h3m3s

Re: PCG, A Family of Better Random Number Generators

#29
post #5

There is a seminar about PCG from its author available on youtube. https://www.youtube.com/watch?v=45Oet5qjlms Its a bit long but I highly recommend it. I learned a lot about RNGs from it.

So good. I'm only about 20 minutes into it, but it addresses so many of the questions and ideas I've had about RNG.

Re: PCG, A Family of Better Random Number Generators

#30

Wow talk about a coincidence - I just implemented this algorithm today as the RNG for some bootstrapped statistic code. One thing I can say is it very fast, but the code for seeding is not great on any platform without /dev/random.

I implemented the mersenne twister to generate 2d planets in a galaxy of a game I am working on a while ago.. I didn't know about this pcg and it's an interesting read!

I had been limited in selection on the random number generator reproducibility (so that each planet is only stored as the seed for the generator)

I'll have a try later on, it'd be interesting how a sampling of planets turn out from both rngs, if they are visually different - the rng is used both for features and for the perlin noise that generates cloud&land textures, so any artifact should come up easy in the textures

Post reply on HN