php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #66718 Please add Mersenne Twister versions of shuffle and array_rand
Submitted: 2014-02-15 01:09 UTC Modified: 2016-09-09 02:44 UTC
Votes:2
Avg. Score:3.5 ± 1.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: php at barrayar dot org Assigned: yohgaki (profile)
Status: Closed Package: SPL related
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at barrayar dot org
New email:
PHP Version: OS:

 

 [2014-02-15 01:09 UTC] php at barrayar dot org
Description:
------------
It would be very helpful if PHP had native Mersenne Twister equivalents for all the various random functions, e.g. mt_shuffle, mt_array_rand.  (I'm not sure if there's any others that would be relevant.)  The MT RNG is superior to the regular srand/rand functions in all respects except this one.  While it's not that hard to implement mt_shuffle and mt_array_rand equivalents in PHP, they would be faster and more standardized if they were native.

(On a related note, it would also be helpful if PHP had a native class for creating separate RNG pools, since sometimes you want to be able to recreate a random sequence from a given seed, but since all mt_rand calls use the same RNG pool, you can't have two concurrent RNG pools.)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-15 12:06 UTC] yohgaki@php.net
-Status: Open +Status: Verified
 [2014-07-15 12:06 UTC] yohgaki@php.net
We may simply use php_mt_rand()
 [2014-07-16 06:22 UTC] yohgaki@php.net
-Assigned To: +Assigned To: yohgaki
 [2015-08-05 12:18 UTC] cmb@php.net
Using php_mt_rand() for array_rand() seems to be reasonable
anyway, to resolve bug #45301.
 [2016-09-09 02:44 UTC] yohgaki@php.net
-Status: Verified +Status: Closed
 [2016-09-09 02:44 UTC] yohgaki@php.net
https://wiki.php.net/rfc/rng_fixes
Implemented.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC