srfi.27
- Sources of Random Bits ¶This module provides SRFI-27 pseudo random generator interface,
using Mersenne Twister algorithm
(see math.mt-random
- Mersenne Twister Random number generator) as the backbone.
The random sources provided in this module is thread safe; multiple thread can use the same random source without breaking its internal state.
[SRFI-27]{srfi.27
}
Returns a random exact integer between [0, n-1], inclusive,
using the default random source.
To set a random seed for this procedure, use random-source-randomize!
or random-source-pseudo-randomize!
on default-random-source
.
[SRFI-27]{srfi.27
}
Returns a random real number between (0, 1), exclusive,
using the default random source.
To set a random seed for this procedure, use random-source-randomize!
or random-source-pseudo-randomize!
on default-random-source
.
[SRFI-27]{srfi.27
}
Keeps the default random source that is used by random-integer
and random-real
.
[SRFI-27]{srfi.27
}
Creates and returns a new random source.
In the current Gauche implementation, it is just a <mersenne-twister>
object. It may be changed in the future implementation.
[SRFI-27]{srfi.27
}
Returns #t
if obj is a random source object.
[SRFI-27]{srfi.27
}
Gets and sets the "snapshot" of the state of the random source s.
State is an opaque object whose content depends on the backbone
generator.
[SRFI-27]{srfi.27
}
Makes an effort to set the state of the random source s to
a truly random state. The current implementation uses the current
time and the process ID to set the random seed.
[SRFI-27]{srfi.27
}
Changes the state of the random source s into the initial state
of the (i, j)-th independent random source,
where i and j are non-negative integers.
This procedure can be used to reuse a random source s as large
number of independent random source, indexed by two non-negative integers.
Note that this procedure is entirely deterministic.
[SRFI-27]{srfi.27
}
Returns a procedure, that takes one integer argument n and
returns a random integer between 0 and n-1 inclusive for every
invocation, from the random source s.
[SRFI-27]{srfi.27
}
Returns a procedure, that takes no argument and
returns a random real between 0 and 1 exclusive for
every invocation, from the random source s.
If unit is given, the random real the returned procedure
generates will be quantized by the given unit, where
0 < unit < 1.