RE: [PHP] seeding using mt_srand();
| From: | Jon Haworth | Date: | Wed, 16 Oct 2002 13:20:53 +0000 |
| Subject: | RE: [PHP] seeding using mt_srand(); | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-120185@lists.php.net to get a copy of this message | ||
Hi Phil,
> I'm doing everything correct, although my random
> numbers don't seem totally random.
There are two reasons for this.
Firstly, you might not be seeding mt_srand() with a sensible seed - if you
always use 23 as your seed, you'll always get the same sequence of random
numbers. You're better off seeding it with the current time or something -
if you haven't already, have a look at the manual page at
http://php.net/mt_srand, there's an example there.
Secondly, random numbers generated by a computer aren't random, they're
what's known as "pseudo-random". To generate truly random numbers you need
something like a decaying radioactive material as your seed source -
http://www.fourmilab.ch/hotbits/ provides exactly
this, so you could always
get your seeds via the web :-)
Cheers
Jon