Crate ran

source ·
Expand description

Mean, lean, fast generation of random numbers of various types. Also filling vectors and vectors of vectors with random numbers

Re-exports

  • pub use crate::error::rerror;
  • pub use crate::error::RanError;
  • pub use crate::error::Re;

Modules

Functions

  • For saving the current value of seed, reproducing the same sequence later
  • Possibly the best generator of f64 in the standardized range [0,1). Based on: `xoshiro256+1.0`` algorithm by David Blackman and Sebastiano Vigna (vigna@acm.org), 2018.
  • Generate an f64 random number in the RangeInclusive min..=max
  • Generates an f64 random number in the standardized range [0,1). It can be linearly transformed to any [min,max] range.
    Very fast, using just three shift and XOR instructions. Based on: George Marsaglia, Xorshift RNGs, Journal of Statistical Software 08(i14), Jan 2003.
  • i64 random number by simple casting
  • Generate an i64 random number in the RangeInclusive min..=max, where the range may span zero.
  • Generates an u8 random number in [0,255].
  • Generates an u16 random number in [0,65535]. We can similarly recast u64 to any other (narrower) type.
  • Possibly the best 64 bits random generator, based on XOR and shift. Adapted from xoshiro256** 1.0 algorithm by David Blackman and Sebastiano Vigna (vigna@acm.org), 2018.
  • Generate an u64 random number in the RangeInclusive min..=max
  • Get random numbers of various smaller unsigned integer types by specifying the number of bits required.
  • Generates vector of size d, of f64 random numbers in [0,1).
  • Generates vector of size d, of f64 random numbers in the RangeInclusive min..=max.
  • Generates vector of size d, of i64 random numbers.
  • Generates vector of size d, of i64 random numbers in the RangeInclusive min..=max. May include zero.
  • Generates vector of size d, of u8 random numbers in [0,255].
  • Generates vector of size d, of u16 random numbers in [0,65535]. We can similarly recast u64 to any other (narrower) type.
  • Generates vector of size d, filled with full range u64 random numbers.
  • Generates vector of size d, of u64 random numbers in the RangeInclusive min..=max
  • Generates n vectors of size d each, of f64 random numbers in [0,1), using the xor-shift algorithm.
  • Generates n vectors of size d, of f64 random numbers in the RangeInclusive min..=max.
  • Generates n vectors of size d each, of i64 random numbers.
  • Generates n vectors of size d, of i64 random numbers in the RangeInclusive min..=max. May include zero.
  • Generates n vectors of size d each, of u8 random numbers in the interval [0,255].
  • Generates n vectors of size d each, of u16 random numbers in the interval [0,65535].
  • Generates n vectors of size d each, of full range u64 random numbers.
  • Generates n vectors of size d, of u64 random numbers in the RangeInclusive min..=max
  • Manual initialisation of SEED (and derived xoshi seeds). When seed == 0, resets SEED to a few elapsed nanoseconds, producing an essentially unpredictable new random sequence. Otherwise sets the SEED to the supplied argument value, which will repeat the same unique sequence for each value.
  • stringifies a generic slice for printing
  • stringifies a generic slice of vectors for printing