#[repr(C)]
pub struct AliasMethodSamplerAtom<E: Copy + PartialEq> { /* private fields */ }

Implementations§

source§

impl<E: Copy + PartialEq> AliasMethodSamplerAtom<E>

source

pub fn u(&self) -> ClosedUnitF64

source

pub fn e(&self) -> E

source

pub fn k(&self) -> E

source

pub fn flip(&mut self)

source

pub fn create( event_weights: &[(E, NonNegativeF64)] ) -> Vec<AliasMethodSamplerAtom<E>>

§Contracts

Pre-condition - debug: event_weights is non-empty

  • ! event_weights.is_empty()

Pre-condition - debug: all event weights are non-negative

  • event_weights.iter().all(|(_e, p)| *p >= 0.0_f64)

Post-condition - debug: stores exactly the input events

  • ret.iter().map(|s| &s.e).eq(old(event_weights).iter().map(|(e, _p)| e))

Post-condition - debug: full buckets sample the same event just in case

  • ret.iter().all(|s| { let full_bucket = s.u == ClosedUnitF64::one(); !full_bucket || (s.e == s.k) })
source

pub fn sample_event<M: MathsCore, G: RngCore<M>>( alias_samplers: &[AliasMethodSamplerAtom<E>], rng: &mut G ) -> E

source

pub fn sample_event_with_cdf_limit<M: MathsCore, G: RngCore<M>>( alias_samplers: &[AliasMethodSamplerAtom<E>], rng: &mut G, limit: ClosedUnitF64 ) -> E

§Contracts

Pre-condition - debug: alias_samplers is non-empty

  • ! alias_samplers.is_empty()

Post-condition - debug: returns one of the weighted events

  • old(alias_samplers).iter().map(|s| s.e).any(|e| e == ret)

Trait Implementations§

source§

impl<E: Clone + Copy + PartialEq> Clone for AliasMethodSamplerAtom<E>

source§

fn clone(&self) -> AliasMethodSamplerAtom<E>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<E> ComputeTypeSet for AliasMethodSamplerAtom<E>
where E: ComputeTypeSet + Copy + PartialEq,

§

type Output<__TypeSetRest: ExpandTypeSet> = <<<__TypeSetRest as ComputeSet>::Output<E> as ComputeSet>::Output<E> as ComputeSet>::Output<ClosedUnitF64>

Extend the set T into a (larger) set containing also the types this type links to. Read more
source§

impl<E: Debug + Copy + PartialEq> Debug for AliasMethodSamplerAtom<E>

source§

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

Formats the value using the given formatter. Read more
source§

impl<E> TypeLayout for AliasMethodSamplerAtom<E>
where E: TypeLayout + Copy + PartialEq,

§

type Inhabited = <And<<ClosedUnitF64 as TypeLayout>::Inhabited, <And<<E as TypeLayout>::Inhabited, <And<<E as TypeLayout>::Inhabited, Inhabited> as ComputeInhabited>::Output> as ComputeInhabited>::Output> as ComputeInhabited>::Output

Marker type for whether the type is inhabited or uninhabited. The associated type must be either [inhabited::Inhabited] or [inhabited::Uninhabited].
source§

const TYPE_LAYOUT: TypeLayoutInfo<'static> = _

Shallow layout of the type.

Auto Trait Implementations§

§

impl<E> Freeze for AliasMethodSamplerAtom<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for AliasMethodSamplerAtom<E>
where E: RefUnwindSafe,

§

impl<E> Send for AliasMethodSamplerAtom<E>
where E: Send,

§

impl<E> Sync for AliasMethodSamplerAtom<E>
where E: Sync,

§

impl<E> Unpin for AliasMethodSamplerAtom<E>
where E: Unpin,

§

impl<E> UnwindSafe for AliasMethodSamplerAtom<E>
where E: UnwindSafe,

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
§

impl<T> Backup for T
where 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> 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
§

impl<T> ExtractDiscriminant for T

§

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
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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
§

impl<T> TypeGraphLayout for T
where T: TypeLayout + ComputeTypeSet,

§

const TYPE_GRAPH: TypeLayoutGraph<'static> = _

Shallow layout of the type.
source§

impl<T> Data for T
where T: Send + Clone,

§

impl<T> Erased for T

source§

impl<T> PortableBitSemantics for T
where T: PortableBitSemantics + ?Sized,

source§

impl<T> StackOnly for T
where T: StackOnly,