Module rand

Source
Expand description

Random number generation.

This module defines several types:

  • RNG algorithms specialized for 8-bit devices: Xabc, Xyza8a, Xyza8b.
  • Classic XorShift algorithms and variations with a smaller state.

The RNGs implement Copy for convenience and versatility. Be careful to not duplicate the state by accident.

The Default implementation uses a fixed seed for convenience. Use a custom seed for unique random sequences.

§Features

All PRNGs require the rand feature, except for XorShift128p, which is always compiled.

Macros§

xorshift_customrand
Constructs a XorShift prng with custom bits, basis, triplet and seed.

Structs§

Lgc16rand
A 16-bit LCG PRNG.
Xabcrand
X ABC PRNG for 8-bit devices.
XorShift8rand
The XorShift8 PRNG.
XorShift16rand
The XorShift16 PRNG.
XorShift32rand
The XorShift32 PRNG.
XorShift64rand
The XorShift64 PRNG.
XorShift128rand
The XorShift128 PRNG.
XorShift128p
The XorShift128+ PRNG.
Xoroshiro128pprand
The Xoroshiro128++ PRNG.
Xyza8arand
A simple 8-bit PRNG with 32-bit of state, based on the XorShift algorithm.
Xyza8brand
A simple 8-bit PRNG with 32-bit of state, based on the XorShift algorithm.