pub struct SFC64 { /* private fields */ }Expand description
The “Small Fast Chaotic” PRNG, originally designed by Chris Doty-Humphrey.
This PRNG holds 256 bits of state (including a 64-bit counter) and generates 64 bits
of output with each step. The minimum cycle length is $2^{64}$, and the expected
period is $~2^{255}$. Independent seeds are guaranteed to not collide within the
first $2^{64}$ steps, although the actual time to collision may be much longer.
This specific implementation passes PractRand with >2TB of output for each of several low-entropy seeds, and >1TB for sets of 8 and 64 parallel streams whose seed differs by only a single bit.
§Seeding (construction)
This generator implements the [SeedableRng] trait. Any method may be used,
and the results are guaranteed to be portable.
Seeding the generator with seed_from_u64 is often the most convenient and
guarantees good pseudorandom statistics.
use hoomd_rand::SFC64;
use rand::SeedableRng;
let rng = SFC64::seed_from_u64(42);See also Seeding RNGs in the Rust Rand book.
§Generation
The generators implements [TryRng] and thus also Rng.
See also the Random Values chapter in the Rust Rand book.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SFC64
impl<'de> Deserialize<'de> for SFC64
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl SeedableRng for SFC64
impl SeedableRng for SFC64
Source§type Seed = [u8; 24]
type Seed = [u8; 24]
u8
arrays (we recommend [u8; N] for some N). Read moreSource§fn seed_from_u64(state: u64) -> Self
fn seed_from_u64(state: u64) -> Self
u64 seed. Read more§fn from_rng<R>(rng: &mut R) -> Selfwhere
R: Rng + ?Sized,
fn from_rng<R>(rng: &mut R) -> Selfwhere
R: Rng + ?Sized,
Rng. Read moreSource§impl TryRng for SFC64
impl TryRng for SFC64
Source§type Error = Infallible
type Error = Infallible
Source§fn try_next_u64(&mut self) -> Result<u64, Self::Error>
fn try_next_u64(&mut self) -> Result<u64, Self::Error>
u64.Source§fn try_next_u32(&mut self) -> Result<u32, Self::Error>
fn try_next_u32(&mut self) -> Result<u32, Self::Error>
u32.impl Eq for SFC64
impl StructuralPartialEq for SFC64
Auto Trait Implementations§
impl Freeze for SFC64
impl RefUnwindSafe for SFC64
impl Send for SFC64
impl Sync for SFC64
impl Unpin for SFC64
impl UnwindSafe for SFC64
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<R> Rng for Rwhere
R: TryRng<Error = Infallible> + ?Sized,
impl<R> Rng for Rwhere
R: TryRng<Error = Infallible> + ?Sized,
§impl<R> RngExt for Rwhere
R: Rng + ?Sized,
impl<R> RngExt for Rwhere
R: Rng + ?Sized,
§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform distribution. Read more§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>where
Self: Sized,
StandardUniform: Distribution<T>,
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>where
Self: Sized,
StandardUniform: Distribution<T>,
§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p of being true. Read more§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. Read more