Struct peroxide::macros::matlab_macro::StdRng
source · pub struct StdRng(_);
Expand description
The standard RNG. The PRNG algorithm in StdRng
is chosen to be efficient
on the current platform, to be statistically strong and unpredictable
(meaning a cryptographically secure PRNG).
The current algorithm used on all platforms is HC-128.
Reproducibility of output from this generator is however not required, thus
future library versions may use a different internal generator with
different output. Further, this generator may not be portable and can
produce different output depending on the architecture. If you require
reproducible output, use a named RNG, for example ChaChaRng
.
Trait Implementations§
source§impl RngCore for StdRng
impl RngCore for StdRng
source§fn fill_bytes(&mut self, dest: &mut [u8])
fn fill_bytes(&mut self, dest: &mut [u8])
Fill
dest
with random data. Read moresource§impl SeedableRng for StdRng
impl SeedableRng for StdRng
§type Seed = <Hc128Rng as SeedableRng>::Seed
type Seed = <Hc128Rng as SeedableRng>::Seed
Seed type, which is restricted to types mutably-dereferencable as
u8
arrays (we recommend [u8; N]
for some N
). Read moresource§fn from_seed(seed: <StdRng as SeedableRng>::Seed) -> StdRng
fn from_seed(seed: <StdRng as SeedableRng>::Seed) -> StdRng
Create a new PRNG using the given seed. Read more
source§fn from_rng<R>(rng: R) -> Result<StdRng, Error>where
R: RngCore,
fn from_rng<R>(rng: R) -> Result<StdRng, Error>where
R: RngCore,
Create a new PRNG seeded from another
Rng
. Read moresource§fn seed_from_u64(state: u64) -> Self
fn seed_from_u64(state: u64) -> Self
Create a new PRNG using a
u64
seed. Read moreimpl CryptoRng for StdRng
Auto Trait Implementations§
impl RefUnwindSafe for StdRng
impl Send for StdRng
impl Sync for StdRng
impl Unpin for StdRng
impl UnwindSafe for StdRng
Blanket Implementations§
source§impl<R> FromEntropy for Rwhere
R: SeedableRng,
impl<R> FromEntropy for Rwhere
R: SeedableRng,
source§fn from_entropy() -> R
fn from_entropy() -> R
Creates a new instance, automatically seeded with fresh entropy. Read more
source§impl<R> Rng for Rwhere
R: RngCore + ?Sized,
impl<R> Rng for Rwhere
R: RngCore + ?Sized,
source§fn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
source§fn gen_range<T>(&mut self, low: T, high: T) -> Twhere
T: PartialOrd<T> + SampleUniform,
fn gen_range<T>(&mut self, low: T, high: T) -> Twhere
T: PartialOrd<T> + SampleUniform,
Generate a random value in the range [
low
, high
), i.e. inclusive of
low
and exclusive of high
. Read moresource§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, '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
source§fn 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 moresource§fn 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 moresource§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 choose<T, 'a>(&mut self, values: &'a [T]) -> Option<&'a T>
fn choose<T, 'a>(&mut self, values: &'a [T]) -> Option<&'a T>
Return a random element from
values
. Read moresource§fn choose_mut<T, 'a>(&mut self, values: &'a mut [T]) -> Option<&'a mut T>
fn choose_mut<T, 'a>(&mut self, values: &'a mut [T]) -> Option<&'a mut T>
Return a mutable pointer to a random element from
values
. Read moresource§fn gen_iter<T>(&mut self) -> Generator<T, &mut Self>where
Standard: Distribution<T>,
fn gen_iter<T>(&mut self) -> Generator<T, &mut Self>where
Standard: Distribution<T>,
👎Deprecated since 0.5.0: use Rng::sample_iter(&Standard) instead
Return an iterator that will yield an infinite number of randomly
generated items. Read more
source§fn gen_weighted_bool(&mut self, n: u32) -> bool
fn gen_weighted_bool(&mut self, n: u32) -> bool
👎Deprecated since 0.5.0: use gen_bool instead
Return a bool with a 1 in n chance of true Read more
source§fn gen_ascii_chars(&mut self) -> AsciiGenerator<&mut Self>
fn gen_ascii_chars(&mut self) -> AsciiGenerator<&mut Self>
👎Deprecated since 0.5.0: use sample_iter(&Alphanumeric) instead
Return an iterator of random characters from the set A-Z,a-z,0-9. Read more