pub enum Distribution {
Fixed(f64),
Weighted(HashMap<OrderedFloat, f64>),
}Expand description
A distribution over read fractions.
Build one with Distribution::fixed or Distribution::weighted,
which validate their inputs. The variants are public for pattern
matching; values built directly are validated again whenever they are
used.
Variants§
Fixed(f64)
A single fixed read fraction (e.g. 0.5 means 50% reads).
Weighted(HashMap<OrderedFloat, f64>)
A weighted distribution over multiple read fractions.
Maps read_fraction -> weight (not yet normalized).
Implementations§
Source§impl Distribution
impl Distribution
Sourcepub fn fixed(read_fraction: f64) -> Result<Self>
pub fn fixed(read_fraction: f64) -> Result<Self>
Create a fixed distribution with a single read fraction.
§Errors
Returns an error if read_fraction is not in [0.0, 1.0].
Sourcepub fn weighted(weights: &[(f64, f64)]) -> Result<Self>
pub fn weighted(weights: &[(f64, f64)]) -> Result<Self>
Create a weighted distribution from pairs of
(read_fraction, weight). Validates but does not
normalize; call Distribution::canonicalize for normalization.
§Errors
Returns an error if any fraction is not in [0.0, 1.0], any weight is negative or not finite, the slice is empty, or all weights are 0.
Repeated fractions have their weights added together.
Sourcepub fn canonicalize(&self) -> Result<Canonical>
pub fn canonicalize(&self) -> Result<Canonical>
Canonicalize this distribution into a map of
read_fraction -> probability where probabilities
sum to 1.0. Zero-weight entries are excluded.
§Errors
Returns an error if any fraction is outside [0, 1], any weight is negative or not finite, or the total weight is not positive.
Trait Implementations§
Source§impl Clone for Distribution
impl Clone for Distribution
Source§impl Debug for Distribution
impl Debug for Distribution
Source§impl PartialEq for Distribution
impl PartialEq for Distribution
impl StructuralPartialEq for Distribution
Source§impl TryFrom<f64> for Distribution
Convenience conversions so callers can pass a plain f64.
impl TryFrom<f64> for Distribution
Convenience conversions so callers can pass a plain f64.
Auto Trait Implementations§
impl Freeze for Distribution
impl RefUnwindSafe for Distribution
impl Send for Distribution
impl Sync for Distribution
impl Unpin for Distribution
impl UnsafeUnpin for Distribution
impl UnwindSafe for Distribution
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more