4 ms·
Because it permanently prevents all bugfixes for a major library class. And java.util.Random has some whopping bugs. If you need determinism, then the proper
by SeanLuke 3y ago
Because it permanently prevents all bugfixes for a major library class. And java.util.Random has some whopping bugs.
If you need determinism, then the proper thing to do is use your own RNG. There's been a good Mersenne Twister implementation on Java since 1999. But a system-wide generator should never be beholden to determinism.
- jibe 3y agoIf you need determinism, and the standard library is deterministic, it seems reasonable to use the standard library.
- SeanLuke 3y agoEven if its high bits go 1 0 1 0 1 0 1 0 ... ?
- _a_a_a_ 3y agoI would say that's a bug in the RNG, nothing to do with any determinism issue
- adgjlsfhk1 3y agoThe point is that if you document your rng as deterministic, you can't fix any bugs.
- _a_a_a_ 3y agowhy do you believe that? Can you explain why not?
- adgjlsfhk1 3y agobecause those bugfixes will change the random numbers generated
- _a_a_a_ 3y agoThat's fine (if you document it). Repeatability may mean 'repeatability over the same program instance/minor version/major instance'. It's fine if you're clear. But ISWYM too.
- _a_a_a_ 3y agoLinks to these whopping bugs pls? I also don't think you've justified why determinism from a seed is a bad thing.
- SeanLuke 3y agoName another language where random() is deterministic. Ask yourself why that is. As to bugs. Let's start with the famous one: http://alife.co.uk/nonrandom/ http://alife.co.uk/nonrandom/ This is due to boneheaded mistakes in Sun's choice of constants for its LCG and errors in its bit-handling. These are massive mistakes, which it can no longer fix. Next, there's an outstanding bug in nextBytes(), which generates ints and then cuts them into bytes (a big no-no for this particular LCG). Some unfortunate omissions: nextChar(), nextShort(), nextByte() are missing, and there is no save-state procedure. There is no nextDouble() method that is inclusive for one or exclusive for zero. There was a notorious bug in nextGaussian() which would take the log of 0 and then divide it by 0, but that has long been fixed. :-) [And some other bugs which were fixed early on despite Sun's claim that it couldn't fix bugs due to its stupid nondeterminism promise. For an RNG!]
- _a_a_a_ 3y ago> Name another language where random() is deterministic pretty well all of them, surely? eg. https://learn.microsoft.com/en-us/sql/t-sql/functions/rand-transact-sql?view=sql-server-ver16 https://learn.microsoft.com/en-us/sql/t-sql/functions/rand-t... "For a specified seed value, the result returned is always the same." Pretty well every language I'm aware of does it this way. Are we even talking about the same thing? As for the others you point out, I'm afraid I can't speak for that. I'll just have to accept what you say.
- adgjlsfhk1 3y agoJulia, for example promises that seeded random numbers will only be the same within the minor version and there's a 3rd party package if you need reproducible random numbers. Guaranteeing cross version random number compatibility comes at a pretty major cost for performance (as new better algorithms are discovered) and removes your ability to bugfix the random number generator.