note 111243 added to function.mt-rand
| From: | HayleyWatson | Date: | Tue, 29 Jan 2013 22:56:44 +0000 |
| Subject: | note 111243 added to function.mt-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193434@lists.php.net to get a copy of this message | ||
Another graphical comparison of rand() and mt_rand(). It effectively draws a graph showing how the
last generated number affects the next by plotting the numbers in consecutive pairs against each
other.
<?php
header("Content-type: image/png");
$sizex=800;
$sizey=800;
$img = imagecreatetruecolor(2 * $sizex,$sizey);
$black = imagecolorallocate($img,0, 0, 0);
imagefilledrectangle($img, 0, 0, 2 * $sizex, $sizey, imagecolorallocate($img, 255, 255, 255));
$p = 0;
for($i=0; $i < 100000; $i++) {
$np = rand(0,$sizex);
imagesetpixel($img, $p, $np, $black);
$p = $np;
}
$p = 0;
for($i=0; $i < 100000; $i++) {
$np = mt_rand(0,$sizex);
imagesetpixel($img, $p + $sizex, $np, $black);
$p = $np;
}
imagepng($img);
imagedestroy($img);
?>
----
Server IP: 69.147.83.199
Probable Submitter: 122.57.198.66
----
Manual Page -- http://php.net/manual/en/function.mt-rand.php
Edit -- https://master.php.net/note/edit/111243
Del: integrated -- https://master.php.net/note/delete/111243/integrated
Del: useless -- https://master.php.net/note/delete/111243/useless
Del: bad code -- https://master.php.net/note/delete/111243/bad+code
Del: spam -- https://master.php.net/note/delete/111243/spam
Del: non-english -- https://master.php.net/note/delete/111243/non-english
Del: in docs -- https://master.php.net/note/delete/111243/in+docs
Del: other reasons-- https://master.php.net/note/delete/111243
Reject -- https://master.php.net/note/reject/111243
Search -- https://master.php.net/manage/user-notes.php