For Development HEAD DRAFTSearch (procedure/syntax/module):

11.46 srfi.194 - Random data generators (SRFI)

Module: srfi.194

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.

Random sources

Parameter: current-random-source

[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).

Function: with-random-source random-source thunk

[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.

Function: make-random-source-generator i

[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!.

Uniform distributions

Function: make-random-integer-generator lower-bound upper-bound

[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.

Function: make-random-u1-generator
Function: make-random-u8-generator
Function: make-random-s8-generator
Function: make-random-u16-generator
Function: make-random-s16-generator
Function: make-random-u32-generator
Function: make-random-s32-generator
Function: make-random-u64-generator
Function: make-random-s64-generator

[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).

Function: clamp-real-number lower-bound upper-bound value

[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).

Function: make-random-real-generator lower-bound upper-bound

[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).

Function: make-random-rectangular-generator re-lower-bound re-upper-bound im-lower-bound im-upper-bound
Function: make-random-polar-generator [origin] mag-lower-bound mag-upper-bound :optional angle-lower-bound angle-upper-bound

[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.

Function: make-random-boolean-generator

[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).

Function: make-random-char-generator string

[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).

Function: make-random-string-generator k string

[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).

Nonuniform distributions

Function: make-bernoulli-generator p

[SRFI-194]{srfi.194}

Function: make-binomial-generator n p

[SRFI-194]{srfi.194}

Function: make-categorical-generator weight-vec

[SRFI-194]{srfi.194}

Function: make-normal-generator :optional mean deviation

[SRFI-194]{srfi.194}

Function: make-exponential-generator mean

[SRFI-194]{srfi.194}

Function: make-geometric-generator p

[SRFI-194]{srfi.194}

Function: make-poisson-geneartor L

[SRFI-194]{srfi.194}

Function: make-zipf-generator N :optional s q

[SRFI-194]{srfi.194}

Function: make-sphere-generator n

[SRFI-194]{srfi.194}

Function: make-ellipsoid-generator axes

[SRFI-194]{srfi.194}

Function: make-ball-generator dimensions

[SRFI-194]{srfi.194}

Generator operations

Function: gsampling generator …

[SRFI-194]{srfi.194}



For Development HEAD DRAFTSearch (procedure/syntax/module):
DRAFT