Re:Anatomy of a pseudorandom number generator – visualising ...
by billforsternz on Tuesday July 09, 2013 @12:53AM
(#6011166)
It's not the most elegant code I've ever seen - but I don't otherwise see a red flag. What's your problem with it ? I don't think the worry that a semi-infinite string of legitimate values >250 is going to come out of randomSalsaByte() is a real, practical problem. You may as well worry that the complete works of Shakespeare asciified might come out of the PRNG. In theory it could happen. In practice, it won't happen even once in 10^100 universe lifetimes. The transistors in the CPU are going to spontaneously fail whilst executing the code zillions of times more often.
[ Parent
| on HN ]
Re:Anatomy of a pseudorandom number generator – visualising ...
by axman6 on Tuesday July 09, 2013 @03:22AM
(#6011545)
The issue isn't the potentially infinite loop, it's the fact it creates an uneven distribution of values, giving 0 a 1/250 greater chance of being selected, and thus makes the results of the PRNG more predictable. The article makes this pretty clear...
Re:Anatomy of a pseudorandom number generator – visualising ...
by billforsternz on Tuesday July 09, 2013 @04:43PM
(#6015324)
What part of "ignoring the off by one error" in the parent don't you get ? Edit: Sorry, unnecessarily snarky, and I could have made my (now uneditable) post clearer by saying ">=250" rather than ">250".