Pseudo-randomness
Uses
-
-
Seeds
(Pseudo-)random series in Leibniz are deterministic. They are computed from a seed value. If you use the same seed value, you get the same series.
Seeds are non-zero bit patterns, represented as natural numbers in Leibniz:
Note: this subsort definition is not strictly correct: valid seeds are fixed-size unsigned non-zero integers, i.e. a subset of LzRandom
uses 256-bit seeds. Describing this properly in Leibniz' sort system would require a distinct sort hierarchy for fixed-size integers, which is not yet done.
The bits of a seed should ideally be chosen randomly. Small integer literals are therefore not good choices, having most bits set to zero. For convenience, you can get a good seed from any integer (including a small one) via
Random series
The construction of a deterministic pseudo-random series from an initial seed produces at each iteration a new value in the series and an updated seed from which the following values are computed. In the following, we call the values of the series its elements , and the combinations of values and seeds its items .
A series of random values of sort
An item of a random series is the tuple combining each element with the random seed for the continuation of the series:
An element can thus be obtained as the first value in an item:
Example
See Random integers