Saturday, July 23, 2011

random number generators

Of late, there have been many concerns, raised in general by our disgruntled operators, that the random number being generated is not good enough. We have been using java's secure random generator which is very very good and so the possibility of someone guessing the next no in sequence is impossibly low. But I was asked to do some searches for some other algorithms and so it began. In the very first search I found out that there are much better algorithms available openly like mersenne twister or xor shift rng with huge period and good randomness. I found that xor shift rng algorithm can be easily coded and so after some more searches, the code was ready. We launched it on the test machine and I set the sample size to 2000 (pretty low, but that is what our operators do, take the latest 2000 values, i know it is pretty weird but...). When I compared the 2 results, one from the secure random generator and one from the xor shift rng, the results looked more or less same. There were some results which were favoured more, while there were some which were not favoured at all. Then I increased the sample size to 300000 and let it run. This time when I compared the result, the xor shift rng's results did look more balanced as the count of individual results was more or less same to the average count that should have come. As of now we will put in the changes to only 1 game and then we will see.

No comments: