pub struct LcgRng { /* private fields */ }Expand description
Minimal LCG (MMIX variant) pseudo-random number generator.
Uses the Knuth MMIX constants for a full-period 64-bit LCG.
CRITICAL: next_bool() uses bit 32, NOT bit 0 (bit 0 has period 2 in MMIX LCG).
Implementations§
Source§impl LcgRng
impl LcgRng
Sourcepub fn next_bool(&mut self) -> bool
pub fn next_bool(&mut self) -> bool
Return a random bool. Uses bit 32 (NOT bit 0) for better statistical quality.
Sourcepub fn next_usize(&mut self, n: usize) -> usize
pub fn next_usize(&mut self, n: usize) -> usize
Return a random usize in [0, n).
Sourcepub fn next_range(&mut self, lo: f64, hi: f64) -> f64
pub fn next_range(&mut self, lo: f64, hi: f64) -> f64
Return a uniform f64 in [lo, hi).
Sourcepub fn next_normal(&mut self) -> f64
pub fn next_normal(&mut self) -> f64
Draw from a standard normal distribution via Box-Muller.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LcgRng
impl RefUnwindSafe for LcgRng
impl Send for LcgRng
impl Sync for LcgRng
impl Unpin for LcgRng
impl UnsafeUnpin for LcgRng
impl UnwindSafe for LcgRng
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