Skip to main content

SimRng

Struct SimRng 

Source
pub struct SimRng {
    state: u64,
}
Expand description

Deterministic xorshift64 RNG seeded by FNV-1a over a simulation identity.

Fields§

§state: u64

Implementations§

Source§

impl SimRng

Source

fn new_state(seed: u64) -> Self

Source

pub fn for_iteration( seed_base: u64, chunk_id: &str, iteration_index: u32, ) -> Self

Constructs the stable stream for a simulation iteration.

The base seed and iteration index are hashed in little-endian byte order; the chunk identifier is hashed as its exact UTF-8 bytes.

Source

pub fn from_prefix(prefix: u64, iteration_index: u32) -> Self

Constructs a stable iteration stream from a seed_prefix result.

Source

pub fn next_u64(&mut self) -> u64

Advances the xorshift64 state and returns the next 64-bit draw.

Source

pub fn next_f64(&mut self) -> f64

Returns a uniform f64 in [0.0, 1.0) using the high 53 bits of one draw.

Source

pub fn next_bool_at_prob(&mut self, p: f64) -> bool

Returns true with fractional probability p.

Source

pub fn range_u32(&mut self, minimum: u32, maximum: u32) -> u32

Samples an integer uniformly from [minimum, maximum).

Source

pub fn gaussian(&mut self, mean: f64, standard_deviation: f64) -> f64

Samples a Gaussian value with the Box-Muller transform.

Trait Implementations§

Source§

impl Debug for SimRng

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.