Skip to content

Commit

Permalink
Document dependencies between PCG streams
Browse files Browse the repository at this point in the history
  • Loading branch information
vks committed May 7, 2021
1 parent 30d2d98 commit 9121d39
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion rand_pcg/src/pcg128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ use rand_core::{le, Error, RngCore, SeedableRng};
/// Despite the name, this implementation uses 32 bytes (256 bit) space
/// comprising 128 bits of state and 128 bits stream selector. These are both
/// set by `SeedableRng`, using a 256-bit seed.
///
/// Note that two generators with different stream parameters may be closely
/// correlated.
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct Lcg128Xsl64 {
Expand Down Expand Up @@ -74,7 +77,10 @@ impl Lcg128Xsl64 {

/// Construct an instance compatible with PCG seed and stream.
///
/// Note that PCG specifies default values for both parameters:
/// Note that two generators with different stream parameters may be closely
/// correlated.
///
/// PCG specifies the following default values for both parameters:
///
/// - `state = 0xcafef00dd15ea5e5`
/// - `stream = 0xa02bdbf7bb3c0a7ac28fa16a64abf96`
Expand Down
8 changes: 7 additions & 1 deletion rand_pcg/src/pcg64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const MULTIPLIER: u64 = 6364136223846793005;
/// Despite the name, this implementation uses 16 bytes (128 bit) space
/// comprising 64 bits of state and 64 bits stream selector. These are both set
/// by `SeedableRng`, using a 128-bit seed.
///
/// Note that two generators with different stream parameter may be closely
/// correlated.
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct Lcg64Xsh32 {
Expand Down Expand Up @@ -74,7 +77,10 @@ impl Lcg64Xsh32 {

/// Construct an instance compatible with PCG seed and stream.
///
/// Note that PCG specifies default values for both parameters:
/// Note that two generators with different stream parameters may be closely
/// correlated.
///
/// PCG specifies the following default values for both parameters:
///
/// - `state = 0xcafef00dd15ea5e5`
/// - `stream = 0xa02bdbf7bb3c0a7`
Expand Down

0 comments on commit 9121d39

Please sign in to comment.