Struct pcg_rand::Pcg32Basic
source · pub struct Pcg32Basic { /* private fields */ }
Expand description
A low overhead very simple PCG impementation
This is mostly useful for demonstrating how PCG works.
If you want better statistical performance you should use one of the predefined types like
Pcg32
.
Implementations
sourceimpl Pcg32Basic
impl Pcg32Basic
sourcepub fn new_unseeded() -> Pcg32Basic
pub fn new_unseeded() -> Pcg32Basic
Creates a new PCG without specifying a seed.
WARNING: Every PCG created with this method will produce the same
output. In most cases a seeded PCG will be more useful, please check
the references for rand::SeedableRng
and rand::FromEntropy
for
methods to seed a PCG.
Trait Implementations
sourceimpl RngCore for Pcg32Basic
impl RngCore for Pcg32Basic
sourcefn fill_bytes(&mut self, dest: &mut [u8])
fn fill_bytes(&mut self, dest: &mut [u8])
Fill
dest
with random data. Read moresourceimpl SeedableRng for Pcg32Basic
impl SeedableRng for Pcg32Basic
type Seed = PcgSeeder<u64>
type Seed = PcgSeeder<u64>
Seed type, which is restricted to types mutably-dereferencable as
u8
arrays (we recommend [u8; N]
for some N
). Read moresourcefn from_seed(seed: Self::Seed) -> Pcg32Basic
fn from_seed(seed: Self::Seed) -> Pcg32Basic
Create a new PRNG using the given seed. Read more
sourcefn seed_from_u64(state: u64) -> Self
fn seed_from_u64(state: u64) -> Self
Create a new PRNG using a
u64
seed. Read moreAuto Trait Implementations
impl RefUnwindSafe for Pcg32Basic
impl Send for Pcg32Basic
impl Sync for Pcg32Basic
impl Unpin for Pcg32Basic
impl UnwindSafe for Pcg32Basic
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<R> FromEntropy for Rwhere
R: SeedableRng,
impl<R> FromEntropy for Rwhere
R: SeedableRng,
sourcefn from_entropy() -> R
fn from_entropy() -> R
Creates a new instance, automatically seeded with fresh entropy. Read more
sourceimpl<R> Rng for Rwhere
R: RngCore + ?Sized,
impl<R> Rng for Rwhere
R: RngCore + ?Sized,
sourcefn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
sourcefn gen_range<T, B1, B2>(&mut self, low: B1, high: B2) -> Twhere
T: SampleUniform,
B1: SampleBorrow<T>,
B2: SampleBorrow<T>,
fn gen_range<T, B1, B2>(&mut self, low: B1, high: B2) -> Twhere
T: SampleUniform,
B1: SampleBorrow<T>,
B2: SampleBorrow<T>,
Generate a random value in the range [
low
, high
), i.e. inclusive of
low
and exclusive of high
. Read moresourcefn 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
sourcefn sample_iter<T, D, 'a>(&'a mut self, distr: &'a D) -> DistIter<'a, D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D, 'a>(&'a mut self, distr: &'a D) -> DistIter<'a, D, Self, T>where
D: Distribution<T>,
Self: Sized,
Create an iterator that generates values using the given distribution. Read more
sourcefn fill<T>(&mut self, dest: &mut T)where
T: AsByteSliceMut + ?Sized,
fn fill<T>(&mut self, dest: &mut T)where
T: AsByteSliceMut + ?Sized,
Fill
dest
entirely with random bytes (uniform value distribution),
where dest
is any type supporting AsByteSliceMut
, namely slices
and arrays over primitive integer types (i8
, i16
, u32
, etc.). Read moresourcefn try_fill<T>(&mut self, dest: &mut T) -> Result<(), Error>where
T: AsByteSliceMut + ?Sized,
fn try_fill<T>(&mut self, dest: &mut T) -> Result<(), Error>where
T: AsByteSliceMut + ?Sized,
Fill
dest
entirely with random bytes (uniform value distribution),
where dest
is any type supporting AsByteSliceMut
, namely slices
and arrays over primitive integer types (i8
, i16
, u32
, etc.). Read moresourcefn 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 moresourcefn 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 moresourcefn choose<T, 'a>(&mut self, values: &'a [T]) -> Option<&'a T>
fn choose<T, 'a>(&mut self, values: &'a [T]) -> Option<&'a T>
👎Deprecated since 0.6.0: use SliceRandom::choose instead
Return a random element from
values
. Read more