Posted by geoffp on 08/30/06 12:41
Apparently seeding mt_srand with different integers can produce identical
series of mt_rand results. Specifically, every pair of consecutive even and
odd numbers produces the same series - see below. This is a nuisance for
me. Am I doing something wrong? I'm using PHP 4.3.4 on a windows box.
Thanks
Geoff
mt_srand(0); echo " 0 new rnd =" . mt_rand() . " rnd =" . mt_rand() . " rnd
=" . mt_rand() . "<BR>";
mt_srand(1); echo " 1 new rnd =" . mt_rand() . " rnd =" . mt_rand() . " rnd
=" . mt_rand() . "<BR>";
mt_srand(2); echo " 2 new rnd =" . mt_rand() . " rnd =" . mt_rand() . " rnd
=" . mt_rand() . "<BR>";
mt_srand(3); echo " 3 new rnd =" . mt_rand() . " rnd =" . mt_rand() . " rnd
=" . mt_rand() . "<BR>";
mt_srand(4); echo " 4 new rnd =" . mt_rand() . " rnd =" . mt_rand() . " rnd
=" . mt_rand() . "<BR>";
mt_srand(100000); echo " 100000 new rnd =" . mt_rand() . " rnd =" .
mt_rand() . " rnd =" . mt_rand() . "<BR>";
mt_srand(100001); echo " 100001 new rnd =" . mt_rand() . " rnd =" .
mt_rand() . " rnd =" . mt_rand() . "<BR>";
mt_srand(100002); echo " 100002 new rnd =" . mt_rand() . " rnd =" .
mt_rand() . " rnd =" . mt_rand() . "<BR>";
mt_srand(100003); echo " 100003 new rnd =" . mt_rand() . " rnd =" .
mt_rand() . " rnd =" . mt_rand() . "<BR>";
mt_srand(100004); echo " 100004 new rnd =" . mt_rand() . " rnd =" .
mt_rand() . " rnd =" . mt_rand() . "<BR>";
produces
0 new rnd =1898087491 rnd =2091264893 rnd =1090025303
1 new rnd =1898087491 rnd =2091264893 rnd =1090025303
2 new rnd =1309289693 rnd =1266233749 rnd =2011030501
3 new rnd =1309289693 rnd =1266233749 rnd =2011030501
4 new rnd =265425943 rnd =110448983 rnd =1971643347
100000 new rnd =863778341 rnd =827028059 rnd =1038256368
100001 new rnd =863778341 rnd =827028059 rnd =1038256368
100002 new rnd =1020061831 rnd =477025457 rnd =1071505930
100003 new rnd =1020061831 rnd =477025457 rnd =1071505930
100004 new rnd =2050501876 rnd =406342065 rnd =79708900
[Back to original message]
|