Live data from Hacker News

PCG, A Family of Better Random Number Generators

pcg-random.org

51–57 of 57 posts

Re: PCG, A Family of Better Random Number Generators

#51
post #42

Earlier quoted context omitted.

Great talk! The video is also linked from the site, under 'Video' in the banner: http://www.pcg-random.org/posts/stanford-colloquium-talk.htm... For those who didn’t bother poking around and are interested in random number generation and C++, the blog also great: http://www.pcg-random.org/blog/

All credits should go to George Marsaglia (who died in 2011). He invented the XorShift method (2003), the LCG with good hyperplane behavior (1968), and the modern method of combining multiple poorly behaving RNGs (via function combination and output mapping) to create modern RNGs, not to mention the "diehard" tests he developed which are used to evaluate the performance of RNGs (1995). This "PCG" algorithm, which is…

https://en.wikipedia.org/wiki/Xorshift

Re: PCG, A Family of Better Random Number Generators

#52
post #47
post #46

Earlier quoted context omitted.

I must have done something wrong, but I tried the basic C implementation ( https://github.com/imneme/pcg-c-basic ) on a quick Diehard-like test and it failed. I'm still trying to understand why. Probably not its fault, just that the code is not as forgiving and ready-to-consume as I had expected.

It passed for me. Where did you get the diehard test? If you compiled it directly from http://www.stat.fsu.edu/pub/diehard/ then it is because that source is broken.

Try using Dieharder. It incorporates most of the Diehard tests, as well as other tests and is much more rigorous.

sudo apt-get install dieharder

http://www.phy.duke.edu/~rgb/General/dieharder.php

If you make a GSL interface for the RNG it will make using dieharder much easier

Re: PCG, A Family of Better Random Number Generators

#53

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…

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.

ChaCha is fast. very fast. see just below: https://news.ycombinator.com/item?id=9890599 I'm not sure why they marked it as "fairly slow" in the table in the OP.

Re: PCG, A Family of Better Random Number Generators

#54
post #52
post #47

Earlier quoted context omitted.

It passed for me. Where did you get the diehard test? If you compiled it directly from http://www.stat.fsu.edu/pub/diehard/ then it is because that source is broken.

Try using Dieharder. It incorporates most of the Diehard tests, as well as other tests and is much more rigorous. sudo apt-get install dieharder http://www.phy.duke.edu/~rgb/General/dieharder.php If you make a GSL interface for the RNG it will make using dieharder much easier

[deleted]

Re: PCG, A Family of Better Random Number Generators

#55
post #52
post #47

Earlier quoted context omitted.

It passed for me. Where did you get the diehard test? If you compiled it directly from http://www.stat.fsu.edu/pub/diehard/ then it is because that source is broken.

Try using Dieharder. It incorporates most of the Diehard tests, as well as other tests and is much more rigorous. sudo apt-get install dieharder http://www.phy.duke.edu/~rgb/General/dieharder.php If you make a GSL interface for the RNG it will make using dieharder much easier

How do you build dieharder on windows? I guess you just don't...

Re: PCG, A Family of Better Random Number Generators

#56
post #47
post #46

Earlier quoted context omitted.

I must have done something wrong, but I tried the basic C implementation ( https://github.com/imneme/pcg-c-basic ) on a quick Diehard-like test and it failed. I'm still trying to understand why. Probably not its fault, just that the code is not as forgiving and ready-to-consume as I had expected.

It passed for me. Where did you get the diehard test? If you compiled it directly from http://www.stat.fsu.edu/pub/diehard/ then it is because that source is broken.

I actually tried a modified OCaml implementation of a very simple test. The issue is probably due to bad seeding/initialization: if I use the given static seed, it passes, but if I try to provide any other seed, it fails on at least one test.

I'll try to find a more complete/better tested port, or try to do it myself.

Re: PCG, A Family of Better Random Number Generators

#57

Earlier quoted context omitted.

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.

ChaCha is fast. very fast. see just below: https://news.ycombinator.com/item?id=9890599 I'm not sure why they marked it as "fairly slow" in the table in the OP.

Fast and slow are all relative - ChaCha is relatively fast but PGC is faster.
Post reply on HN