Module rand_pcg

PCG family of fast, non-cryptographic random number generators.


rand_pcg provides random number generators based on the PCG family of algorithms. These are fast, have good statistical quality, and are portable — given the same seed they produce identical output on all platforms.

They are not cryptographically secure. Use rand_chacha when security matters.

The main types are:

Example

use rand::SeedableRng;
use rand::Rng;
use rand_pcg::Pcg32;

let mut rng = Pcg32::seed_from_u64(42);

let value: u32 = rng.random();
let in_range: f64 = rng.random_range(0.0..1.0);
let coin: bool = rng.random();