News for hackers. Stuff that matters.
Re:Efficiently Generating a Number in a Range by nerdponx on Wednesday July 25, 2018 @09:36AM (#17609104)
This is well-timed. I don't know much about different random number generators but I do know that we recently had an problem where RNG was a serious performance bottleneck.
Re:Efficiently Generating a Number in a Range by simias on Wednesday July 25, 2018 @12:34PM (#17610542)
Note that this article is not really about RNGs themselves, but mostly how to use one to generate an unbiased number within a given range from a "raw" RNG output which typically generates a stream of 32 or 64bit integers.

Regarding the performance of RNGs themselves it's mostly bound by how "random" your want your NG to be. If you don't really care about quality and need very good performance, for instance to procedurally generate assets in a videogame, there are extremely fast and somewhat decent PRNGs out there, such as XorShift. Of course you won't use that to generate PGP keys...

Re:Efficiently Generating a Number in a Range by by on Wednesday July 25, 2018 @12:37PM (#17610571)
I only skimmed the article, so maybe they said this, but for choosing from a small range, for example 0..51, you can get several of these from a 32 bit random number with this algorithm

https://stackoverflow.com/questions/6046918/how-to-generate-...

You should be able to run a 64 bit PRNG once and pick at least 8 random cards from a deck.

Re:Efficiently Generating a Number in a Range by ballenf on Wednesday July 25, 2018 @12:47PM (#17610662)
The article's conclusion was that the PRNG generation method used is usually not the bottleneck, but how you take that to get a result is. Don't know if that applies to the algorithm linked, but the author's point was that bottlenecks are more likely to arise in the code that surrounds the PRNG algorithm than in the call to PRNG itself.
Re:Efficiently Generating a Number in a Range by throwawaymath on Wednesday July 25, 2018 @02:48PM (#17611751)
Would you mind talking a little bit more about the scenario and bottleneck? If you're concerned about anonymity you can just email me directly. I'm working on a research project to examine real world scenarios when the fastest cryptographic PRNGs are legitimately insufficient; your case might be useful.