pub struct SimRng {
state: u64,
}Expand description
Deterministic xorshift64 RNG seeded by FNV-1a over a simulation identity.
Fields§
§state: u64Implementations§
Source§impl SimRng
impl SimRng
fn new_state(seed: u64) -> Self
Sourcepub fn for_iteration(
seed_base: u64,
chunk_id: &str,
iteration_index: u32,
) -> Self
pub fn for_iteration( seed_base: u64, chunk_id: &str, iteration_index: u32, ) -> Self
Constructs the stable stream for a simulation iteration.
The base seed and iteration index are hashed in little-endian byte order; the chunk identifier is hashed as its exact UTF-8 bytes.
Sourcepub fn from_prefix(prefix: u64, iteration_index: u32) -> Self
pub fn from_prefix(prefix: u64, iteration_index: u32) -> Self
Constructs a stable iteration stream from a seed_prefix result.
Sourcepub fn next_u64(&mut self) -> u64
pub fn next_u64(&mut self) -> u64
Advances the xorshift64 state and returns the next 64-bit draw.
Sourcepub fn next_f64(&mut self) -> f64
pub fn next_f64(&mut self) -> f64
Returns a uniform f64 in [0.0, 1.0) using the high 53 bits of one draw.
Sourcepub fn next_bool_at_prob(&mut self, p: f64) -> bool
pub fn next_bool_at_prob(&mut self, p: f64) -> bool
Returns true with fractional probability p.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SimRng
impl RefUnwindSafe for SimRng
impl Send for SimRng
impl Sync for SimRng
impl Unpin for SimRng
impl UnsafeUnpin for SimRng
impl UnwindSafe for SimRng
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more