Mersenne_Twister
class Mersenne_Twister
This provides a deterministic pseudo-random sequence that is seedable
Since PHP 5.2.1 mt_srand() and mt_rand() don't generate predictable sequences since PHP 5.2.1. The following code:
$code = 12345; $MT = new \Tsugi\Util\Mersenne_Twister($code); for($i=0; $i < 30; $i++ ) { $ran = $MT->getNext(0,6); echo $ran." "; }
Will always print out:
2 3 3 6 5 1 5 3 4 2 1 6 5 4 0 6 0 2 0 3 5 6 6 3 1 3 2 6 3 3
Note that this is written for a 64-bit system and will generate different sequences on 32 and 64 bit systems.
Constants
MAX |
|
Methods
No description
No description
Get the next pseudo-random number in the sequence
No description
No description
Details
at line 33
__construct($seed = null)
at line 40
setSeed($seed)
at line 71
getNext($min = null, $max = null)
Get the next pseudo-random number in the sequence
Returns the next pseudo-random number in the range specified. The $max and $min are inclusive. If $max and $min are omitted a large integer is returned.