Next: , Previous: , Up: SRFI-27   [Contents][Index] Random Sources

Function: make-random-source

Create a new random source. The stream of random numbers obtained from each random source created by this procedure will be identical, unless its state is changed by one of the procedures below.

Function: random-source? object

Tests whether object is a random source. Random sources are a disjoint type.

Function: random-source-randomize! source

Attempt to set the state of the random source to a truly random value. The current implementation uses a seed based on the current system time.

Function: random-source-pseudo-randomize! source i j

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 provides a mechanism to obtain a large number of independent random sources (usually all derived from the same backbone generator), indexed by two integers. In contrast to random-source-randomize!, this procedure is entirely deterministic.

The state associated with a random state can be obtained an reinstated with the following procedures:

Function: random-source-state-ref source
Function: random-source-state-set! source state

Get and set the state of a random source. No assumptions should be made about the nature of the state object, besides it having an external representation (i.e. it can be passed to write and subsequently read back).