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

12.37 math.random.xos - Xorshift random number generator

Module: math.random.xos

This module implements one of xorshift-family pseudo random generator (in the current implementation, we use Xoshiro256++). It has smaller state size than Mersenne-Twister.

Class: <xos-random>

{math.random.xos} A class to packate the state of Xoshiro256 PRNG (the name stands for Xor-Shift-Rotate 256bits).

Function: make-xos-random :optional seed private?

{math.random.xos} Creates and returns a new <xos-random> PRNG instance. An optional seed argument must be a u64 integer if given, providing a random seed. We process this sheed with split-mix 64 to fill the state, so any seed value is valid. When omitted, a fixed seed value is used.

By default, access to the PRNG is mutexed. If you know there’s only one thread accessing it, you can pass a true value to private? to avoid the overhead.

Function: xos-random-copy xos :key private?

{math.random.xos} Returns a new <xos-random> PRNG instance that copies the state of the source xos. Both source and created PRNG will produce the same random sequence. This can be used to take ‘snapshot‘ of the PRNG state.

The private-ness (not mutexing PRNG) is not automatically passed to the new instance. To make the new instance mutex-less, pass a true value to The keyword argument private?.

Function: xos-random-copy! dst-xos src-xos

{math.random.xos} Copies src-xos’s PRNG state over dst-xos’s PRNG state. Previous state of dst-xos is destoryed, and both xos PRNG will produce the same random sequence afterwards.

The private-ness of dst-xos is kept as is; it is not a part of the PRNG state.

This can be used to “restore” previously saved PRNG state.

Function: xos-random-state=? xos1 xos2

{math.random.xos} Compare to xos PRNGs’ states. If this returns #t, both PRNGs will produce the same random sequence.

The private-ness of xos1 and xos2 are not compared.

Function: xos-random-get-seed xos

{math.random.xos} Returns the seed value (u64 integer) used to initialize xos.

Function: xos-random-set-seed! xos seed

{math.random.xos} Set the seed value (u64 integer) to the PRNG xos, and reinitialize it.

Function: xos-random-u64 xos

{math.random.xos}

Function: xos-random-real xos
Function: xos-random-real0 xos

{math.random.xos}

Function: xos-random-fill-u32vector! xos vec
Function: xos-random-fill-u64vector! xos vec
Function: xos-random-fill-f32vector! xos vec
Function: xos-random-fill-f64vector! xos vec

{math.random.xos}



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