(Replying to PARENT post)
*[1] en.cppreference.com/w/cpp/numeric
(Replying to PARENT post)
(Replying to PARENT post)
Good article
(Replying to PARENT post)
"The one operation that was not observed was substracting the pid from the time. More research into this subject is warranted."
It's actually simple (even if still not effective on pid wraparound) - pid numbers grow, at a rate of at least 1 per program execution. Time grows at around 1 second per second. If you substituted pid from time, there's a good chance you would get the same seed by running the app twice in a row.
So it's added instead, so that it always grows. And we pretend the wraparound happens very rarely.
Broken behaviour? Sure. Practical solution that works for 99% cases where non-critical randomness is required? Definitely.
(Replying to PARENT post)
Just use urandom. Or getentropy() if your OS supports it.
If you're not using it for cryptographic purposes, then I don't see why it matters. :)
(Replying to PARENT post)
As far as I know, Lua does not include Mersenne Twister. math.random() is just C rand().
(Replying to PARENT post)
Using float/double random()'s don't always help either, because floating point multiplication has non-uniform errors. Instead, what you really need is:
Although it's better to replace random() itself with something that uses real entropy.