Have you ever needed to generate a random number in code? whether it's for rolling a dice, or shuffling a set, this tweet thread is here for you! There's no reason that it should be easy or obvious, very experienced programmers repeat common mistakes. I did, before I learned ...
-
Show this thread
-
Replying to @colmmacc
Nice epic thread on random number generation. I came here to point out "rand() Considered Harmful" talk which is an awesome take on this https://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful … and slides https://view.officeapps.live.com/op/view.aspx?src=http%3a%2f%2fvideo.ch9.ms%2fsessions%2fgonat%2f2013%2fSTLGN13rand.pptx … In C++ we discourage the use of rand() and have <random>https://stackoverflow.com/a/17798317/1708801 …
1 reply 4 retweets 21 likes -
Replying to @shafikyaghmour @colmmacc
I'd consider <random> harmful, too.https://arvid.io/2018/06/30/on-cxx-random-number-generator-quality/ …
1 reply 0 retweets 5 likes -
Replying to @ArvidGerstmann @colmmacc
I am not sure it is not my specialty, it is not clear to me where these details matter. I guess cryptography and related is one of them. While your write was interesting it did not give me enough context. What if I just want to do simple Monte-carlo are they still ok?
2 replies 0 retweets 1 like -
My 2c: it’s malpractice for the default random in a general purpose language to be anything other than a system-backed CSPRNG.
5 replies 4 retweets 21 likes -
Replying to @stephentyrone @shafikyaghmour and
It’s totally okay to have a fast/seedable alternative, of course, but mt is a bizarrely stone-age choice.
2 replies 0 retweets 2 likes -
Replying to @stephentyrone @shafikyaghmour and
MT isn't even "stone age". It's "kool-aid". It was *always* worse than most other choices, even LCG.
1 reply 1 retweet 3 likes -
Replying to @RichFelker @shafikyaghmour and
True. I’m giving a little benefit of the doubt because that wasn’t as well-known back in the dark ages.
1 reply 0 retweets 1 like -
Replying to @stephentyrone @shafikyaghmour and
Statistically a 128-bit LCG with just upper 32 bits used is pretty damn decent.
2 replies 0 retweets 0 likes
And orders of magnitude smaller than MT in state size, code size, & conceptual complexity.
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.