8 stable releases (4 major)

4.1.0 Sep 1, 2020
4.0.1 Sep 1, 2020
3.0.1 Jul 25, 2019
3.0.0 Jun 24, 2019
0.1.1 Apr 8, 2018

#2192 in Algorithms

Download history 19/week @ 2024-02-18 6/week @ 2024-02-25 7/week @ 2024-03-03 10/week @ 2024-03-10 1/week @ 2024-03-17 64/week @ 2024-03-31

77 downloads per month
Used in 2 crates

MIT license

12KB
156 lines

pcg-rs

Build status Documentation License

Synopsis

This is a port of the PCG random number generation libary, made for C and C++, to Rust.

The library implements the RngCore trait, which automatically implements the Rng trait, providing a standard interface to generate and sample random numbers.

Note: with the 1.0.0 release of pcg-rs, the old sampling methods have been deprecated, please use the sampling methods implemented via the Rng trait instead.

http://www.pcg-random.org

Usage

This crate offers no_std compatibility through the std feature. It is enabled by default, but if you want to use no_std, you can add the package like this:

[dependencies.pcg]
version = "4.0"
default-features = false

This crate also has optional support for serde, which you can enable as a feature:

[dependencies.pcg]
version = "4.0"
features = ["std", "serde"]

Example Usage

use rand::prelude::*;
use pcg::Pcg;

// Initialize the default PCG rng state
let mut rng = Pcg::default();

// Generate some boolean using the standard `gen()` method, which generates the
// appropriate type with type inference
let random_bool: bool = rng.gen();

Dependencies

~235KB