pub struct R30 {
pub state: u32,
}
Expand description
A Rule30 CA based PRNG
Fields§
§state: u32
The current state of the Automata (a bit-string of len 32)
Implementations§
Source§impl R30
impl R30
pub fn new(seed: u32) -> Self
pub fn center() -> Self
Sourcepub fn next_u32(&mut self) -> u32
pub fn next_u32(&mut self) -> u32
Sample 32 bits from the center of the automata (done by iterating the automata 32 times) and interpret the resultant bitstring as u32
Sourcepub fn next_u64_in(&mut self, a: u64, b: u64) -> u64
pub fn next_u64_in(&mut self, a: u64, b: u64) -> u64
Generate a u64 in [a, b]
Sourcepub fn next_u32_in(&mut self, a: u32, b: u32) -> u32
pub fn next_u32_in(&mut self, a: u32, b: u32) -> u32
Generate a u32 in [a, b]
Sourcepub fn rand_choice<'a, T>(&'a mut self, xs: &'a Vec<T>) -> &T
pub fn rand_choice<'a, T>(&'a mut self, xs: &'a Vec<T>) -> &T
Uniformly sample from a Vec
Trait Implementations§
Source§impl RngCore for R30
impl RngCore for R30
Source§fn fill_bytes(&mut self, dest: &mut [u8])
fn fill_bytes(&mut self, dest: &mut [u8])
Fill
dest
with random data. Read moreimpl Copy for R30
impl Eq for R30
impl StructuralPartialEq for R30
Auto Trait Implementations§
impl Freeze for R30
impl RefUnwindSafe for R30
impl Send for R30
impl Sync for R30
impl Unpin for R30
impl UnwindSafe for R30
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<R> Rng for R
impl<R> Rng for R
Source§fn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Generate a random value in the given range. Read more
Source§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Sample a new value, using the given distribution. Read more
Source§fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Create an iterator that generates values using the given distribution. Read more
Source§fn gen_bool(&mut self, p: f64) -> bool
fn gen_bool(&mut self, p: f64) -> bool
Return a bool with a probability
p
of being true. Read moreSource§fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
Return a bool with a probability of
numerator/denominator
of being
true. I.e. gen_ratio(2, 3)
has chance of 2 in 3, or about 67%, of
returning true. If numerator == denominator
, then the returned value
is guaranteed to be true
. If numerator == 0
, then the returned
value is guaranteed to be false
. Read more