Hold a procedure that can be used to generate a new randomness source.
It is initialised to
make-random-source/mrg32k3a. For example,
it can be used as:
(define source ((random-source-maker))) (define integer (random-source-integer-maker source)) (display (integer)) -| <a random integer>
(parameterise ((random-source-maker make-random-source/device)) (let* ((source ((random-source-maker))) (integer (random-source-integer-maker source))) (display (integer)))) -| <a random integer>
Test if obj is a randomness source. Objects of type randomness source are distinct from all other types of objects.
Get and set the current state of source. The purpose of these functions is to allow saving and restoring the state between sessions (for example, save the state to a file and reload it later).
The state value is always a vector whose first element is a symbol describing the generator. The other elements of the vector depend on the kind of generator: Refer to generator’s documentation for their format.
Reseed source to a new state. integers-maker must be a a
generator of random integer numbers, like the ones returned by
random-source-integers-maker. Notice that many random sources
require integer-makers to return integers representable with
random-source-seed! is used to reseed a source, some
generator will invoke integers-maker a fixed and known number of
times, other generators will invoke it a configurable number of times,
other generators will invoke it until it first returns
generators will invoke it until the returned numbers have some desired
This function returns the number of times integers-maker will be
called; if the return value is
#f: integers-maker will be
invoked until it first returns
#f; if the return value is
infinity: integers-maker will be invoked until it returns numbers
with some desired property.
Move ahead number-of-steps randomness source’s state. What this means exactly depends on the type of source.
The following procedures return a closure rand to generate pseudo–random integers and real numbers using a randomness source. If an application obtains and uses several rand procedures for the same randomness source, a call to any of these procedures advances the state of source. Hence, the procedures do not produce the same sequence of random integers each, but rather share a state.
Return a procedure rand to generate random integers using source. rand takes a single argument U, which must be a positive integer, and returns the next uniformly distributed random integer X in the interval 0 <= X < U by advancing the state of source.
Return a procedure rand which, when invoked with no arguments,
generates random real numbers X in the range
0 < X < 1
using source. X=0 and X=1 are excluded in order to
allow \log(X) and \log(1-X) without the danger of a
The optional parameter unit determines the quantization of the
output; to have effect, unit must be a number such that
unit < 1, if unit is greater than, or equal to, 1 the
generated numbers will have the default unit. The numbers created by
rand are spaced by at most unit. Generating real numbers, for details.