better random numbers

John Rose john.r.rose at oracle.com
Fri Sep 3 01:01:38 UTC 2021


On Sep 2, 2021, at 4:35 PM, John Rose <john.r.rose at oracle.com<mailto:john.r.rose at oracle.com>> wrote:

The state of the art for PRNGs (pseudo-random number generators) is
much advanced since ju.Random was written.

Surely at some point we will refresh our APIs that produce random
numbers.  In fact, we have added SplittableRandom, but I think the
state of the art is farther enough along to consider another refresh.

Well, I didn’t know about https://openjdk.java.net/jeps/356
when I wrote the previous, so I’m a little late to be as helpful
as I hoped to be.  Still, Joe and Brian B. (thanks guys for handing
me the Missing Clue) lead me to hope we can add options to cover
the PCG algorithms, if (as I think) they turn out to be useful.

The 128-bit PCG state with the 64-bit multiplier of da942042e4dd58b5
looks especially promising to me.  It’s used here:

https://github.com/imneme/pcg-cpp/blob/ffd522e7188bef30a00c74dc7eb9de5faff90092/include/pcg_random.hpp#L176

O’Neill says that’s her PRNG of choice for most purposes is
pcg64_fast (defined in the file above using that multiplier).
It competes better with the xoshiro family performance
than the shootout figures provided by the xoshiro developers
would seem to indicate.  And the state size for pcg64_fast is
128 bits which (I think) is about half the size of a xoshiro state.



More information about the core-libs-dev mailing list