dimanche 15 février 2015

Is there a bug in the C++ random generator?

I've written a small program at http://ift.tt/1FfJHVQ. It simulates a roulette and calculates the times a sequence of same color sectors with length n, has been reached. So if you spin it 4 times and you get RED, BLACK, BLACK, BLACK that will give you 2 sequences with lengths 1, and 1 sequence of lengths 2 and 3.


The problem comes when I spin it more than a million times. Then the longest sequence reached is absolutely always 15. I've tried it with 500 000 000 000 spins and yet again, the longest sequence is 15. I've done the math, I've tried it on java and this seems to be an abnormal behavior. I've tried putting the seed srand() in the main, in the constructor of the Roulette class and in the method calling rand(), but there seems to be no difference.


I'm running it on windows on MinGW's latest version as for this date. The IDE I'm using is Eclipse.


I can't find any place where there could be a mistake, so thanks in advance if you try to investigate :)


Aucun commentaire:

Enregistrer un commentaire