|
Posted by Andy Hassall on 08/30/06 19:03
On Wed, 30 Aug 2006 12:41:07 GMT, "geoffp" <fwerfrf@jhgjhfggb.com> wrote:
>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.
Weird, but see the comments in ext/standard/rand.c:
"
Notes (SJC): I do not know what the initial state requirements
of the Mersenne Twister are, but it seems this seeding generator
could be better. It achieves the maximum period for its modulus
(2^30) iff x_initial is odd (p. 20-21, Sec. 3.2.1.2, Knuth); if
x_initial can be even, you have sequences like 0, 0, 0, ...;
2^31, 2^31, 2^31, ...; 2^30, 2^30, 2^30, ...; 2^29, 2^29 + 2^31,
2^29, 2^29 + 2^31, ..., etc. so I force seed to be odd below.
"
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Navigation:
[Reply to this message]
|