You are here: Re: odd mt_srand behavior « PHP Programming Language « IT news, forums, messages
Re: odd mt_srand behavior

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация