Re: Really random ?

From: Date: Thu, 05 Mar 2009 03:42:18 +0000
Subject: Re: Really random ?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-43261@lists.php.net to get a copy of this message
Kenan Sulayman wrote: > Hello PHP internals, > > I've been running several million tests regarding the > arithmetically-random-functions. > > The returning value at the end: > Avg: mt_r: 1073848211.4106 r: 16384.155746685 ~8016909 > Avg: mt_r: 1073904131.0286 r: 16384.164383921 ~8503575 > Avg: mt_r: 1074010520.4456 r: 16384.091213092 ~13136327 > > Shape: > Avg: mt_r: { avg of mt_rand() } r: { avg of rand() } ~ { value of $i ( > iterations ) } > > Means: > Average of mersenne twister in 8016909 it's is 1073848211.4106 ( > corresponding to that in 8503575 it's the avg. is 1073904131.0286). > That's acceptable. > > The rand(x) function alters the avg in 5M iterations really by just 0.1 ? > Wow, that's creepy. > You're exhausting the period. It's not creepy, it's expected, for a random number generator with only 16 bits of state. > Is there any way - to make it better ( or a bit as good as the m_twister is > ? ) ? > No, apparently it's conventional to expose whatever crap PRNG the system has lying around instead of forcing programmers to use one of the two perfectly good ones that PHP bundles. -- Tim Starling

« previous php.internals (#43261) next »