PRNG: Raise warning and/or provide better pseudo random generator?
| From: | Yasuo Ohgaki | Date: | Mon, 22 Feb 2016 21:30:24 +0000 |
| Subject: | PRNG: Raise warning and/or provide better pseudo random generator? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-91347@lists.php.net to get a copy of this message | ||
Hi all,
We have issue on pseudo random generators generates only odd/even
numbers.
https://bugs.php.net/bug.php?id=63174
https://news.ycombinator.com/item?id=9941364
We should raise E_WARNING/E_NOTICE if user supplies random number
range that generated random number cannot be random at least.
Patch for rand/mt_rand.
https://gist.github.com/yohgaki/1519f65dffd66735bafe
It seems we need more reliable(fool proof) pseudo random generator.
Anyone working on this?
We may extends rand()/mt_rand() so that they work with larger range by
calling random generators multiple times. If this is implemented, the
patch raises errors is not required. mt_rand() extension breaks compatibility
with other MT rand implementations, but we already broke it. Therefore, it
should not matter. (This was the reason why mt_rand() wasn't made to support
64bit int, IIRC)
IMO, we should provide better pseudo random generators than now.
Any comments?
P.S. I think we should fix mt_rand() to be true MT rand. Function
named mt_rand()
is not being MT rand is not a nice thing to keep _forever_.
--
Yasuo Ohgaki
yohgaki@ohgaki.net