|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
math.mt-random- Mersenne Twister Random number generator
Provides a pseudo random number generator (RNG) based on "Mersenne Twister" algorithm developed by Makoto Matsumoto and Takuji Nishimura. It is fast, and has huge period of 2^19937-1. See MT, for details about the algorithm.
For typical use cases of random number generators,
we recommend to use
srfi-27 which is implemented
on top of this module and provides portable API.
You should use this module directly only when you need
functions that aren’t available through
A class to encapsulate the state of Mersenne Twister RNG. Each instance of this class has its own state, and can be used as an independent source of random bits if initialized by individual seed.
The random seed value can be given at the instantiation time
:seed initialization argument, or by using
mt-random-set-seed! described below.
(define m (make <mersenne-twister> :seed (sys-time))) (mt-random-real m) ⇒ 0.10284287848537865 (mt-random-real m) ⇒ 0.463227748348805 (mt-random-real m) ⇒ 0.8628500643709712 …
Sets random seed value seed to the Mersenne Twister RNG mt.
Seed can be an arbitrary positive exact integer,
or arbitrary length of u32vector (See section
srfi-4 - Homogeneous vectors).
If it is an integer, the lower 32bits are used for initialization.
If it is a u32vector, up to 624 elements are used for initialization.
Retrieves and reinstalls the state of Mersenne Twister RNG mt.
The state is represented by a u32vector of 625 elements. The state
can be stored elsewhere, and then restored to an instance of
<mersenne-twister> to continue to generate the pseudo random
Returns a random real number between 0.0 and 1.0.
1.0 is not included in the range.
include 0.0 either, while
Excluding 0.0 is from the draft SRFI-27.
Returns a random exact positive integer between 0 and range-1. Range can be any positive exact integer.
Fills the given uniform vector by the random numbers.
mt-random-fill-u32vector!, the elements are filled
by exact positive integers between 0 and 2^32-1.
mt-random-fill-f64vector!, it is filled by an inexact
real number between 0.0 and 1.0, exclusive.
If you need a bunch of random numbers at once, these are much faster than getting one by one.
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]|
This document was generated on July 19, 2014 using texi2html 1.82.