ID: 43108 Updated by: [EMAIL PROTECTED] Reported By: cetra3 at hotmaill dot com -Status: Open +Status: Bogus Bug Type: Math related Operating System: Windows XP PHP Version: 5.2.4 New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. There is nothing PHP-specific about rand() as it relies on libc's rand. Remember that those functions can only produce pseudo-random numbers. Patterns can emerge because of that. Previous Comments: ------------------------------------------------------------------------ [2007-10-31 17:14:23] crescentfreshpot at yahoo dot com > with numbers 5 and 10 producing lower counts Oh I see now. ------------------------------------------------------------------------ [2007-10-31 17:01:29] crescentfreshpot at yahoo dot com http://en.wikipedia.org/wiki/Principle_of_indifference A hundred million times is a shitload dude. ------------------------------------------------------------------------ [2007-10-26 09:44:47] cetra3 at hotmaill dot com Description: ------------ The function Rand will produce predictable results. Reproduce code: --------------- <?php $array_random = array_fill(1,10,1); for($i=0;$i<100000000;$i++) { $array_random[rand(1,10)]++; } print_r($array_random); ?> Expected result: ---------------- This should produce an array which counts how many times each number is picked at random. It should return a different result each time. Actual result: -------------- Instead of getting purely random responses, we get predictable ones, in this example there will be tainted results, with numbers 5 and 10 producing lower counts: Array ( [1] => 10000594 [2] => 10000610 [3] => 10000633 [4] => 10000589 [5] => 9997562 [6] => 10000606 [7] => 10000568 [8] => 10000620 [9] => 10000645 [10] => 9997583 ) You will always see these types of return values. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43108&edit=1