Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43261 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36488 invoked from network); 5 Mar 2009 03:42:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2009 03:42:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=tstarling@wikimedia.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=tstarling@wikimedia.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain wikimedia.org from 66.111.4.29 cause and error) X-PHP-List-Original-Sender: tstarling@wikimedia.org X-Host-Fingerprint: 66.111.4.29 out5.smtp.messagingengine.com Received: from [66.111.4.29] ([66.111.4.29:51131] helo=out5.smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 34/93-18706-12A4FA94 for ; Wed, 04 Mar 2009 22:42:26 -0500 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 92D412E2841; Wed, 4 Mar 2009 22:42:22 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 04 Mar 2009 22:42:22 -0500 X-Sasl-enc: xJKsH+WNdhYsevQT25slRDFCQzEh2XxKdYsAKasVIn0m 1236224541 Received: from [192.168.0.103] (CPE-144-136-114-224.nsw.bigpond.net.au [144.136.114.224]) by mail.messagingengine.com (Postfix) with ESMTPSA id 4EB48D7DF; Wed, 4 Mar 2009 22:42:21 -0500 (EST) Message-ID: <49AF4A1A.2040205@wikimedia.org> Date: Thu, 05 Mar 2009 14:42:18 +1100 User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: Kenan Sulayman CC: PHP internals References: In-Reply-To: X-Enigmail-Version: 0.95.0 OpenPGP: id=BF976370 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Really random ? From: tstarling@wikimedia.org (Tim Starling) 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