Live data from Hacker News

C++ Seeding Surprises (2015)

pcg-random.org

1–10 of 26 posts

Re: C++ Seeding Surprises (2015)

#5
This talks about 'bad' seeding quite a lot. But it really depends on what you need what is bad and what is good. Sometimes you need to have a reproducible program so you need to write the random number generator yourself and/or otherwise fix the algorithm. Then you can use '5' as the seed. This is quite often good enough for simulations. Sometimes you want to create cryptographic randomness. Then you need to somewhere find some seed of true randomness that is not guessable. In a computer game where the level needs some random elements just seeding the random number generator with the current time might be fine. And so on.

Re: C++ Seeding Surprises (2015)

#6
post #3

Is it possible to initialize a prng in C++’s std correctly?

No one uses the header as it's cursed and the usual cult of backwards compatibility ensures it'll stay that way. There are several high quality alternatives that people use.

I've found it easier to write my own PRNG than to use the std. Using the std PRNG is about as buggy as my implementation, so the trade-off is reasonable. I usually need non-cryptographically strong PRNGs, so xorshift128+ is sufficient.

Re: C++ Seeding Surprises (2015)

#7
post #3

Is it possible to initialize a prng in C++’s std correctly?

No one uses the header as it's cursed and the usual cult of backwards compatibility ensures it'll stay that way. There are several high quality alternatives that people use.

How did it get into the standard then?

Re: C++ Seeding Surprises (2015)

#8
post #3

Is it possible to initialize a prng in C++’s std correctly?

No one uses the header as it's cursed and the usual cult of backwards compatibility ensures it'll stay that way. There are several high quality alternatives that people use.

Sadly, people that don't know better use std::mt19937 all the time :-(.

Re: C++ Seeding Surprises (2015)

#9
post #3

Is it possible to initialize a prng in C++’s std correctly?

If you're aware/concerned about seeding, you probably aren't using the C++ std prng (mt19937) anyway -- other prngs have desirable properties like vastly smaller state, better performance, or cryptographic security.

Re: C++ Seeding Surprises (2015)

#10
post #7

Earlier quoted context omitted.

No one uses the header as it's cursed and the usual cult of backwards compatibility ensures it'll stay that way. There are several high quality alternatives that people use.

How did it get into the standard then?

It was better than the bad, C interface LCG rand(), I guess. (There are LCG parameters that make for ~objectively better PRNGs than MT, but rand()'s parameters aren't great and its state is too small.)
Post reply on HN