[−][src]Struct rstat::Probability
Type representing the probability an event.
This struct is just a wrapper around f64
that strictly enforces that the
probability lies in \([0, 1]\).
Methods
impl Probability
[src]
pub fn new(p: f64) -> Result<Self, InvalidProbabilityError>
[src]
Construct a probability, checking that the argument lies in \([0, 1]\).
Examples
use rstat::Probability; // Invalid probabilities: assert!(Probability::new(1.5).is_err()); assert!(Probability::new(-1.0).is_err()); // Valid probabilities: assert!(Probability::new(0.0).is_ok()); assert!(Probability::new(0.5).is_ok()); assert!(Probability::new(1.0).is_ok());
pub fn new_unchecked(p: f64) -> Probability
[src]
Construct a probability without checking for validity.
pub fn zero() -> Probability
[src]
Returns a new Probability with value 0.
pub fn half() -> Probability
[src]
Returns a new Probability with value 0.5.
pub fn one() -> Probability
[src]
Returns a new Probability with value 1.
pub fn unwrap(self) -> f64
[src]
Unwrap the probability and return the internal f64
.
Examples
use rstat::Probability; assert_eq!(Probability::half().unwrap(), 0.5);
pub fn is_valid(&self) -> bool
[src]
Returns true if the probability lies in \([0, 1]\).
Examples
use rstat::Probability; assert!(Probability::new_unchecked(0.5).is_valid()); assert!(!Probability::new_unchecked(10.0).is_valid());
pub fn ln(self) -> f64
[src]
Return the natural logarithm of the probability: \(\ln{p}\).
Examples
use rstat::Probability; assert_eq!(Probability::one().ln(), 0.0);
pub fn log2(self) -> f64
[src]
Return the base-2 logarithm of the probability: \(\log_2{p}\).
Examples
use rstat::Probability; assert_eq!(Probability::half().log2(), -1.0);
pub fn powf(self, e: f64) -> f64
[src]
Return the probability raised to the power e
: \(p^e\).
Examples
use rstat::Probability; assert_eq!(Probability::half().powf(2.5), 0.1767766952966369);
pub fn powi(self, e: i32) -> f64
[src]
Return the probability raised to the power e
: \(p^e\).
Examples
use rstat::Probability; assert_eq!(Probability::half().powi(2), 0.25);
Trait Implementations
impl<'a> Add<&'a Probability> for Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the +
operator.
fn add(
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
[src]
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
impl<'a, 'b> Add<&'a Probability> for &'b Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the +
operator.
fn add(
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
[src]
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
impl<'a> Add<&'a Probability> for f64
[src]
type Output = f64
The resulting type after applying the +
operator.
fn add(self, other: &'a Probability) -> f64
[src]
impl<'a, 'b> Add<&'a Probability> for &'b f64
[src]
type Output = f64
The resulting type after applying the +
operator.
fn add(self, other: &'a Probability) -> f64
[src]
impl<'a> Add<&'a f64> for Probability
[src]
type Output = f64
The resulting type after applying the +
operator.
fn add(self, other: &'a f64) -> f64
[src]
impl<'a, 'b> Add<&'a f64> for &'b Probability
[src]
type Output = f64
The resulting type after applying the +
operator.
fn add(self, other: &'a f64) -> f64
[src]
impl Add<Probability> for Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the +
operator.
fn add(self, other: Probability) -> Result<Probability, InvalidProbabilityError>
[src]
impl<'a> Add<Probability> for &'a Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the +
operator.
fn add(self, other: Probability) -> Result<Probability, InvalidProbabilityError>
[src]
impl Add<Probability> for f64
[src]
type Output = f64
The resulting type after applying the +
operator.
fn add(self, other: Probability) -> f64
[src]
impl<'a> Add<Probability> for &'a f64
[src]
type Output = f64
The resulting type after applying the +
operator.
fn add(self, other: Probability) -> f64
[src]
impl Add<f64> for Probability
[src]
type Output = f64
The resulting type after applying the +
operator.
fn add(self, other: f64) -> f64
[src]
impl<'a> Add<f64> for &'a Probability
[src]
type Output = f64
The resulting type after applying the +
operator.
fn add(self, other: f64) -> f64
[src]
impl Clone for Probability
[src]
fn clone(&self) -> Probability
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Probability
[src]
impl Debug for Probability
[src]
impl Default for Probability
[src]
fn default() -> Probability
[src]
impl Display for Probability
[src]
impl<'a> Div<&'a Probability> for Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the /
operator.
fn div(
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
[src]
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
impl<'a, 'b> Div<&'a Probability> for &'b Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the /
operator.
fn div(
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
[src]
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
impl<'a> Div<&'a Probability> for f64
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, other: &'a Probability) -> f64
[src]
impl<'a, 'b> Div<&'a Probability> for &'b f64
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, other: &'a Probability) -> f64
[src]
impl<'a> Div<&'a f64> for Probability
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, other: &'a f64) -> f64
[src]
impl<'a, 'b> Div<&'a f64> for &'b Probability
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, other: &'a f64) -> f64
[src]
impl Div<Probability> for Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the /
operator.
fn div(self, other: Probability) -> Result<Probability, InvalidProbabilityError>
[src]
impl<'a> Div<Probability> for &'a Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the /
operator.
fn div(self, other: Probability) -> Result<Probability, InvalidProbabilityError>
[src]
impl Div<Probability> for f64
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, other: Probability) -> f64
[src]
impl<'a> Div<Probability> for &'a f64
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, other: Probability) -> f64
[src]
impl Div<f64> for Probability
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, other: f64) -> f64
[src]
impl<'a> Div<f64> for &'a Probability
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, other: f64) -> f64
[src]
impl From<Probability> for f64
[src]
fn from(p: Probability) -> f64
[src]
impl<'a> Mul<&'a Probability> for Probability
[src]
type Output = Probability
The resulting type after applying the *
operator.
fn mul(self, other: &'a Probability) -> Probability
[src]
impl<'a, 'b> Mul<&'a Probability> for &'b Probability
[src]
type Output = Probability
The resulting type after applying the *
operator.
fn mul(self, other: &'a Probability) -> Probability
[src]
impl<'a> Mul<&'a Probability> for f64
[src]
type Output = f64
The resulting type after applying the *
operator.
fn mul(self, other: &'a Probability) -> f64
[src]
impl<'a, 'b> Mul<&'a Probability> for &'b f64
[src]
type Output = f64
The resulting type after applying the *
operator.
fn mul(self, other: &'a Probability) -> f64
[src]
impl<'a> Mul<&'a f64> for Probability
[src]
type Output = f64
The resulting type after applying the *
operator.
fn mul(self, other: &'a f64) -> f64
[src]
impl<'a, 'b> Mul<&'a f64> for &'b Probability
[src]
type Output = f64
The resulting type after applying the *
operator.
fn mul(self, other: &'a f64) -> f64
[src]
impl Mul<Probability> for Probability
[src]
type Output = Probability
The resulting type after applying the *
operator.
fn mul(self, other: Probability) -> Probability
[src]
impl<'a> Mul<Probability> for &'a Probability
[src]
type Output = Probability
The resulting type after applying the *
operator.
fn mul(self, other: Probability) -> Probability
[src]
impl Mul<Probability> for f64
[src]
type Output = f64
The resulting type after applying the *
operator.
fn mul(self, other: Probability) -> f64
[src]
impl<'a> Mul<Probability> for &'a f64
[src]
type Output = f64
The resulting type after applying the *
operator.
fn mul(self, other: Probability) -> f64
[src]
impl Mul<f64> for Probability
[src]
type Output = f64
The resulting type after applying the *
operator.
fn mul(self, other: f64) -> f64
[src]
impl<'a> Mul<f64> for &'a Probability
[src]
type Output = f64
The resulting type after applying the *
operator.
fn mul(self, other: f64) -> f64
[src]
impl Not for Probability
[src]
type Output = Probability
The resulting type after applying the !
operator.
fn not(self) -> Probability
[src]
impl<'_> Not for &'_ Probability
[src]
type Output = Probability
The resulting type after applying the !
operator.
fn not(self) -> Probability
[src]
impl Param for Probability
[src]
type Value = f64
fn value(&self) -> &f64
[src]
fn into_value(self) -> f64
[src]
fn constraints() -> Constraints<Self::Value>
[src]
impl PartialEq<Probability> for Probability
[src]
fn eq(&self, other: &Probability) -> bool
[src]
fn ne(&self, other: &Probability) -> bool
[src]
impl PartialEq<f64> for Probability
[src]
impl PartialOrd<Probability> for Probability
[src]
fn partial_cmp(&self, other: &Probability) -> Option<Ordering>
[src]
fn lt(&self, other: &Probability) -> bool
[src]
fn le(&self, other: &Probability) -> bool
[src]
fn gt(&self, other: &Probability) -> bool
[src]
fn ge(&self, other: &Probability) -> bool
[src]
impl<'a> Rem<&'a Probability> for Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the %
operator.
fn rem(
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
[src]
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
impl<'a, 'b> Rem<&'a Probability> for &'b Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the %
operator.
fn rem(
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
[src]
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
impl<'a> Rem<&'a Probability> for f64
[src]
type Output = f64
The resulting type after applying the %
operator.
fn rem(self, other: &'a Probability) -> f64
[src]
impl<'a, 'b> Rem<&'a Probability> for &'b f64
[src]
type Output = f64
The resulting type after applying the %
operator.
fn rem(self, other: &'a Probability) -> f64
[src]
impl<'a> Rem<&'a f64> for Probability
[src]
type Output = f64
The resulting type after applying the %
operator.
fn rem(self, other: &'a f64) -> f64
[src]
impl<'a, 'b> Rem<&'a f64> for &'b Probability
[src]
type Output = f64
The resulting type after applying the %
operator.
fn rem(self, other: &'a f64) -> f64
[src]
impl Rem<Probability> for Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the %
operator.
fn rem(self, other: Probability) -> Result<Probability, InvalidProbabilityError>
[src]
impl<'a> Rem<Probability> for &'a Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the %
operator.
fn rem(self, other: Probability) -> Result<Probability, InvalidProbabilityError>
[src]
impl Rem<Probability> for f64
[src]
type Output = f64
The resulting type after applying the %
operator.
fn rem(self, other: Probability) -> f64
[src]
impl<'a> Rem<Probability> for &'a f64
[src]
type Output = f64
The resulting type after applying the %
operator.
fn rem(self, other: Probability) -> f64
[src]
impl Rem<f64> for Probability
[src]
type Output = f64
The resulting type after applying the %
operator.
fn rem(self, other: f64) -> f64
[src]
impl<'a> Rem<f64> for &'a Probability
[src]
type Output = f64
The resulting type after applying the %
operator.
fn rem(self, other: f64) -> f64
[src]
impl StructuralPartialEq for Probability
[src]
impl<'a> Sub<&'a Probability> for Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the -
operator.
fn sub(
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
[src]
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
impl<'a, 'b> Sub<&'a Probability> for &'b Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the -
operator.
fn sub(
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
[src]
self,
other: &'a Probability
) -> Result<Probability, InvalidProbabilityError>
impl<'a> Sub<&'a Probability> for f64
[src]
type Output = f64
The resulting type after applying the -
operator.
fn sub(self, other: &'a Probability) -> f64
[src]
impl<'a, 'b> Sub<&'a Probability> for &'b f64
[src]
type Output = f64
The resulting type after applying the -
operator.
fn sub(self, other: &'a Probability) -> f64
[src]
impl<'a> Sub<&'a f64> for Probability
[src]
type Output = f64
The resulting type after applying the -
operator.
fn sub(self, other: &'a f64) -> f64
[src]
impl<'a, 'b> Sub<&'a f64> for &'b Probability
[src]
type Output = f64
The resulting type after applying the -
operator.
fn sub(self, other: &'a f64) -> f64
[src]
impl Sub<Probability> for Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the -
operator.
fn sub(self, other: Probability) -> Result<Probability, InvalidProbabilityError>
[src]
impl<'a> Sub<Probability> for &'a Probability
[src]
type Output = Result<Probability, InvalidProbabilityError>
The resulting type after applying the -
operator.
fn sub(self, other: Probability) -> Result<Probability, InvalidProbabilityError>
[src]
impl Sub<Probability> for f64
[src]
type Output = f64
The resulting type after applying the -
operator.
fn sub(self, other: Probability) -> f64
[src]
impl<'a> Sub<Probability> for &'a f64
[src]
type Output = f64
The resulting type after applying the -
operator.
fn sub(self, other: Probability) -> f64
[src]
impl Sub<f64> for Probability
[src]
type Output = f64
The resulting type after applying the -
operator.
fn sub(self, other: f64) -> f64
[src]
impl<'a> Sub<f64> for &'a Probability
[src]
type Output = f64
The resulting type after applying the -
operator.
fn sub(self, other: f64) -> f64
[src]
impl<'a> Sum<&'a Probability> for f64
[src]
fn sum<I: Iterator<Item = &'a Probability>>(iter: I) -> f64
[src]
impl Sum<Probability> for f64
[src]
fn sum<I: Iterator<Item = Probability>>(iter: I) -> f64
[src]
impl TryFrom<f64> for Probability
[src]
type Error = InvalidProbabilityError
The type returned in the event of a conversion error.
fn try_from(p: f64) -> Result<Self, InvalidProbabilityError>
[src]
Auto Trait Implementations
impl RefUnwindSafe for Probability
impl Send for Probability
impl Sync for Probability
impl Unpin for Probability
impl UnwindSafe for Probability
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
[src]
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
impl<T, Base> RefNum<Base> for T where
T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,
[src]
T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,