Struct necsim_impls_no_std::alias::AliasMethodSampler
source · pub struct AliasMethodSampler<E: Copy + PartialEq> { /* private fields */ }
Implementations§
source§impl<E: Copy + PartialEq> AliasMethodSampler<E>
impl<E: Copy + PartialEq> AliasMethodSampler<E>
sourcepub fn new(event_weights: &[(E, NonNegativeF64)]) -> Self
pub fn new(event_weights: &[(E, NonNegativeF64)]) -> Self
§Contracts
Pre-condition - debug: event_weights is non-empty
! event_weights.is_empty()
Post-condition - debug: stores exactly the input events
ret.Es.iter().eq(old(event_weights).iter().map(|(e, _p)| e))
Post-condition - debug: full buckets sample the same event just in case
ret.Us.iter().zip(ret.Es.iter()).zip(ret.Ks.iter()).all(|((u, e), k)| { let full_bucket = *u == ClosedUnitF64::one(); !full_bucket || (e == k) })
sourcepub fn sample_event<M: MathsCore, G: RngCore<M>>(&self, rng: &mut G) -> E
pub fn sample_event<M: MathsCore, G: RngCore<M>>(&self, rng: &mut G) -> E
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for AliasMethodSampler<E>
impl<E> RefUnwindSafe for AliasMethodSampler<E>where
E: RefUnwindSafe,
impl<E> Send for AliasMethodSampler<E>where
E: Send,
impl<E> Sync for AliasMethodSampler<E>where
E: Sync,
impl<E> Unpin for AliasMethodSampler<E>where
E: Unpin,
impl<E> UnwindSafe for AliasMethodSampler<E>where
E: UnwindSafe,
Blanket Implementations§
§impl<T> Backup for Twhere
T: Clone,
impl<T> Backup for Twhere
T: Clone,
default unsafe fn backup_unchecked(&self) -> T
default unsafe fn __contracts_impl_backup_unchecked(&self) -> T
fn backup(&self) -> BackedUp<Self>
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
§impl<T> ExtractDiscriminant for T
impl<T> ExtractDiscriminant for T
§type Discriminant = <T as ExtractDiscriminantSpec<<T as DiscriminantKind>::Discriminant>>::Ty
type Discriminant = <T as ExtractDiscriminantSpec<<T as DiscriminantKind>::Discriminant>>::Ty
The type of the discriminant, which must satisfy the trait bounds
required by
core::mem::Discriminant
. Read more