Open tqwhite opened 7 years ago
Could you paste the two different code snippets for random number generation using Math.random and pcg? It would help analyzing the issue. Thank you!
Happy to hear from you. Attached is a file that runs either of them. It's simple so don't make fun of me. I'll be interested to know what you learn. pcgTest.js.txt
I am stupid about cryptography so please be kind if this is a stupid point.
Reading about the supposed shortcomings of Math.random(), I looked around and found that PCG is said to be good. Since I'm a Javascript guy, that lead me to you and your implementation.
Just looking to see how it works and what it looks like, I made a loop that generated endless random numbers and checked for duplicates. This library produces a duplicate value after 90-100,000 values, once after only 45k iterations.
Of course, random is random and a sequence of coin tosses produces a run of heads sometimes. A duplicate number isn't against the rules. But, it seems like a bad thing to happen so soon, especially since my main use for generator is generating UUIDs (not that I'm generating even 45k of them anytime soon).
So, I did the same thing with Math.random() and, it's been running for a half hour and no duplicate values.
Do I misunderstand something about random numbers? Is this a flaw?
In any case, thanks for the code.
Best Regards, tqii