Next: srfi.196
- Range objects, Previous: srfi.193
- Command line, Up: Library modules - SRFIs [Contents][Index]
srfi.194
- Random data generators (SRFI)This module provides a set of generators (see gauche.generator
- Generators) that yield
random data of specific distributions.
Gauche has its own random data generator module data.random
(see data.random
- Random data generators), which was a basis of this SRFI,
although procedure names are adjusted to match other SRFIs.
This SRFI also adds several advanced random data generators.
[SRFI-194]{srfi.194} The value of this parameter must be a SRFI-27 random source. Generators created in this module use the value of this parameter at the time of creation as a random source. Changing this after a generator is created won’t affect its behavior.
In Gauche, this is just an alias of random-data-random-source
of data.random
. Rebinding either one affects both srfi.194
and data.random
procedures (see data.random
- Random data generators).
[SRFI-194]{srfi.194}
Calls thunk while binding the parameter current-random-source
to random-source, which must be a random source
object of srfi-27.
[SRFI-194]{srfi.194}
Returns a fresh generator that creates
a new random source by make-random-source
, and
process it with random-source-pseudo-randomize!
with i,
and internal counter j, starting from 0 and incremented
every time the generator is called.
See srfi.27
- Sources of Random Bits, for the details of
make-random-source
and
random-source-pseudo-randomize!
.
[SRFI-194]{srfi.194}
Creates and returns a generator that generates exact integers
between lower-bound (inclusive) and upper-bound
(exclusive).
Same as calling (integers$ (- upper-bound lower-boud) lower-bound)
of data.random
(see data.random
- Random data generators).
Note that this is different from integers-between$
, which
includes the upper bound.
[SRFI-194]{srfi.194}
Creates and returns a generator of fixed-range exact integers.
Calling make-random-u1-generator
is the same as
(integers$ 2)
, and other generators are
the same as uint8s$
, sint8s$
, etc., of
data.random
(see data.random
- Random data generators).
[SRFI-194]{srfi.194} All arguments must be real numbers, and lower-bound must be less than or equal to upper-bound. If value is between two bounds, it is returned as is. If it is smaller than lower-bound, lower-bound is returned. If it is greater than upper-bound, upper-bound is returned.
Similar to Gauche’s build-in clamp
, with different argument
order (see Arithmetics).
[SRFI-194]{srfi.194} Returns a fresh generator that produces a real number between lower-bound and upper-bound, both inclusive.
It is the same as reals-between$
of data.random
(see data.random
- Random data generators).
[SRFI-194]{srfi.194}
Returns a fresh generator that produces a complex number
uniformly within the area specified by the arguments.
They are the same as complexes-rectangular$
and
complexes-polar$
of data.random
(see data.random
- Random data generators), respectively.
See their entries for the details.
[SRFI-194]{srfi.194}
Returns a fresh generator that produces random boolean values.
It is the same as booleans$
of data.random
(see data.random
- Random data generators).
[SRFI-194]{srfi.194} Returns a fresh generator that produces characters uniformly sampled from string. The order of characters within string is irrelevant. You can repeat characters in stirng to increase the chance of that characters to be produced.
It is an error if string is empty.
This is not the same as chars$
, but rather a type-restricted
case of samples$
of data.random
(see data.random
- Random data generators).
[SRFI-194]{srfi.194} Returns a fresh generator that produces a random string of length k and consisting characters uniformly sampled from string.
It is an error if string is empty.
This is not the same as strings-of
of data.random
.
Rather, this can be written as
(strings-of (integers$ k) (samples$ str))
(see data.random
- Random data generators).
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
[SRFI-194]{srfi.194}
Next: srfi.196
- Range objects, Previous: srfi.193
- Command line, Up: Library modules - SRFIs [Contents][Index]