pub struct Probability<T>(/* private fields */)
where
T: FloatBounds;Expand description
Type-safe probability value constrained to [0, 1]
Implementations§
Source§impl<T> Probability<T>where
T: FloatBounds,
impl<T> Probability<T>where
T: FloatBounds,
Sourcepub fn new(value: T) -> Result<Probability<T>, SklearsError>
pub fn new(value: T) -> Result<Probability<T>, SklearsError>
Create a new probability value, returning an error if not in [0, 1]
Sourcepub unsafe fn new_unchecked(value: T) -> Probability<T>
pub unsafe fn new_unchecked(value: T) -> Probability<T>
Create a probability value without validation (unsafe)
§Safety
The caller must ensure the value is in [0, 1]
Sourcepub fn as_f64(self) -> f64where
T: ToPrimitive,
pub fn as_f64(self) -> f64where
T: ToPrimitive,
Convert to f64 for compatibility
Sourcepub fn complement(self) -> Probability<T>
pub fn complement(self) -> Probability<T>
Complement probability (1 - p)
Sourcepub fn sigmoid(x: T) -> Probability<T>
pub fn sigmoid(x: T) -> Probability<T>
Sigmoid function to convert any real number to probability
Trait Implementations§
Source§impl<T> Add for Probability<T>where
T: FloatBounds,
impl<T> Add for Probability<T>where
T: FloatBounds,
Source§type Output = Result<Probability<T>, SklearsError>
type Output = Result<Probability<T>, SklearsError>
The resulting type after applying the
+ operator.Source§fn add(self, other: Probability<T>) -> <Probability<T> as Add>::Output
fn add(self, other: Probability<T>) -> <Probability<T> as Add>::Output
Performs the
+ operation. Read moreSource§impl<T> Clone for Probability<T>where
T: Clone + FloatBounds,
impl<T> Clone for Probability<T>where
T: Clone + FloatBounds,
Source§fn clone(&self) -> Probability<T>
fn clone(&self) -> Probability<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for Probability<T>where
T: Debug + FloatBounds,
impl<T> Debug for Probability<T>where
T: Debug + FloatBounds,
Source§impl<T> Display for Probability<T>where
T: FloatBounds,
impl<T> Display for Probability<T>where
T: FloatBounds,
Source§impl<T> Mul for Probability<T>where
T: FloatBounds,
impl<T> Mul for Probability<T>where
T: FloatBounds,
Source§type Output = Probability<T>
type Output = Probability<T>
The resulting type after applying the
* operator.Source§fn mul(self, other: Probability<T>) -> <Probability<T> as Mul>::Output
fn mul(self, other: Probability<T>) -> <Probability<T> as Mul>::Output
Performs the
* operation. Read moreSource§impl<T> PartialEq for Probability<T>where
T: PartialEq + FloatBounds,
impl<T> PartialEq for Probability<T>where
T: PartialEq + FloatBounds,
Source§impl<T> PartialOrd for Probability<T>where
T: PartialOrd + FloatBounds,
impl<T> PartialOrd for Probability<T>where
T: PartialOrd + FloatBounds,
impl<T> Copy for Probability<T>where
T: Copy + FloatBounds,
impl<T> StructuralPartialEq for Probability<T>where
T: FloatBounds,
Auto Trait Implementations§
impl<T> Freeze for Probability<T>where
T: Freeze,
impl<T> RefUnwindSafe for Probability<T>where
T: RefUnwindSafe,
impl<T> Send for Probability<T>
impl<T> Sync for Probability<T>
impl<T> Unpin for Probability<T>where
T: Unpin,
impl<T> UnwindSafe for Probability<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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