Expand description
This crate implements the xoshiro family of pseudorandom number generators designed by David Blackman and Sebastiano Vigna. They feature high performance and a small state and supersede the previous xorshift-based generators. However, they are not cryptographically secure and their output can be predicted by observing a few samples.
The following generators are implemented:
§64-bit generators
Xoshiro256StarStar
: Recommended for all purposes. Excellent speed and a state space (256 bits) large enough for any parallel application.Xoshiro256PlusPlus
: Recommended for all purposes. Excellent speed and a state space (256 bits) large enough for any parallel application.Xoshiro256Plus
: Recommended for generating 64-bit floating-point numbers. About 15% faster thanXoshiro256StarStar
, but has a low linear complexity in the lowest bits (which are discarded when generating floats), making it fail linearity tests. This is unlikely to have any impact in practise.Xoroshiro128StarStar
: An alternative toXoshiro256StarStar
, having the same speed but using half the state. Only suited for low-scale parallel applications.Xoroshiro128PlusPlus
: An alternative toXoshiro256PlusPlus
, having the same speed but using half the state. Only suited for low-scale parallel applications.Xoroshiro128Plus
: An alternative toXoshiro256Plus
, having the same speed but using half the state. Only suited for low-scale parallel applications. Has a low linear complexity in the lowest bits (which are discarded when generating floats), making it fail linearity tests. This is unlikely to have any impact in practise.Xoshiro512StarStar
: An alternative toXoshiro256StarStar
with more state and the same speed.Xoshiro512PlusPlus
: An alternative toXoshiro256PlusPlus
with more state and the same speed.Xoshiro512Plus
: An alternative toXoshiro512Plus
with more state and the same speed. Has a low linear complexity in the lowest bits (which are discarded when generating floats), making it fail linearity tests. This is unlikely to have any impact in practise.SplitMix64
: Recommended for initializing generators of the xoshiro family from a 64-bit seed. Used for implementingseed_from_u64
.
§32-bit generators
Xoshiro128StarStar
: Recommended for all purposes. Excellent speed.Xoshiro128PlusPlus
: Recommended for all purposes. Excellent speed.Xoshiro128Plus
: Recommended for generating 32-bit floating-point numbers. Faster thanXoshiro128StarStar
, but has a low linear complexity in the lowest bits (which are discarded when generating floats), making it fail linearity tests. This is unlikely to have any impact in practise.Xoroshiro64StarStar
: An alternative toXoshiro128StarStar
, having the same speed but using half the state.Xoroshiro64Star
: An alternative toXoshiro128Plus
, having the same speed but using half the state. Has a low linear complexity in the lowest bits (which are discarded when generating floats), making it fail linearity tests. This is unlikely to have any impact in practise.
The *PlusPlus
generators perform similarly to the *StarStar
generators.
See the xoshiro paper, where the differences are discussed in detail.
§Example
To initialize a generator, use the SeedableRng
trait:
use rand_core::{SeedableRng, RngCore};
use rand_xoshiro::Xoshiro256PlusPlus;
let mut rng = Xoshiro256PlusPlus::seed_from_u64(0);
let x = rng.next_u64();
Re-exports§
pub use rand_core;
Structs§
- Seed512
- 512-bit seed for a generator.
- Split
Mix64 - A splitmix64 random number generator.
- Xoroshiro64
Star - A xoroshiro64* random number generator.
- Xoroshiro64
Star Star - A xoroshiro64** random number generator.
- Xoroshiro128
Plus - A xoroshiro128+ random number generator.
- Xoroshiro128
Plus Plus - A xoroshiro128++ random number generator.
- Xoroshiro128
Star Star - A xoroshiro128** random number generator.
- Xoshiro128
Plus - A xoshiro128+ random number generator.
- Xoshiro128
Plus Plus - A xoshiro128++ random number generator.
- Xoshiro128
Star Star - A xoshiro128** random number generator.
- Xoshiro256
Plus - A xoshiro256+ random number generator.
- Xoshiro256
Plus Plus - A xoshiro256++ random number generator.
- Xoshiro256
Star Star - A xoshiro256** random number generator.
- Xoshiro512
Plus - A xoshiro512+ random number generator.
- Xoshiro512
Plus Plus - A xoshiro512++ random number generator.
- Xoshiro512
Star Star - A xoshiro512** random number generator.