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§

error
Custom error RError

Functions§

get_seed
For saving the current value of seed, reproducing the same sequence later
ran_f64
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.
ran_f64_range
Generate an f64 random number in the RangeInclusive min..=max
ran_fast_f64
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.
ran_i64
i64 random number by simple casting
ran_i64_range
Generate an i64 random number in the RangeInclusive min..=max, where the range may span zero.
ran_u8
Generates an u8 random number in [0,255].
ran_u16
Generates an u16 random number in [0,65535]. We can similarly recast u64 to any other (narrower) type.
ran_u64
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.
ran_u64_range
Generate an u64 random number in the RangeInclusive min..=max
ran_ubits
Get random numbers of various smaller unsigned integer types by specifying the number of bits required.
ranv_f64
Generates vector of size d, of f64 random numbers in [0,1).
ranv_f64_range
Generates vector of size d, of f64 random numbers in the RangeInclusive min..=max.
ranv_i64
Generates vector of size d, of i64 random numbers.
ranv_i64_range
Generates vector of size d, of i64 random numbers in the RangeInclusive min..=max. May include zero.
ranv_u8
Generates vector of size d, of u8 random numbers in [0,255].
ranv_u16
Generates vector of size d, of u16 random numbers in [0,65535]. We can similarly recast u64 to any other (narrower) type.
ranv_u64
Generates vector of size d, filled with full range u64 random numbers.
ranv_u64_range
Generates vector of size d, of u64 random numbers in the RangeInclusive min..=max
ranvv_f64
Generates n vectors of size d each, of f64 random numbers in [0,1), using the xor-shift algorithm.
ranvv_f64_range
Generates n vectors of size d, of f64 random numbers in the RangeInclusive min..=max.
ranvv_i64
Generates n vectors of size d each, of i64 random numbers.
ranvv_i64_range
Generates n vectors of size d, of i64 random numbers in the RangeInclusive min..=max. May include zero.
ranvv_u8
Generates n vectors of size d each, of u8 random numbers in the interval [0,255].
ranvv_u16
Generates n vectors of size d each, of u16 random numbers in the interval [0,65535].
ranvv_u64
Generates n vectors of size d each, of full range u64 random numbers.
ranvv_u64_range
Generates n vectors of size d, of u64 random numbers in the RangeInclusive min..=max
set_seeds
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.
stringv
stringifies a generic slice for printing
stringvv
stringifies a generic slice of vectors for printing