pub struct Probability<T: Num>(pub T);
Expand description
An independent probability.
This represents some probability of some abstract, isolated event occuring. Note that the even have to be isolated (independent of any other event) for the operations to be correct. As such, you shouldn’t do calculations with conditional events. Stronger methods needs to be used for this.
This newtype simply wraps some numeral type and provides it with operations:
&
for independent and.|
for independent or.^
for independent mutual exclusivity.!
for inverse probability.
Tuple Fields§
§0: T
Implementations§
Source§impl<T: Num + PartialOrd> Probability<T>
impl<T: Num + PartialOrd> Probability<T>
Sourcepub fn certain() -> Probability<T>
pub fn certain() -> Probability<T>
The probability representing a “almost certain” condition.
“Almost certain” (a.c.) should not be equated with “certain”, because something can be practically certain, but not impossible to fail. For example, pick a random natural number from an uniform distribution. Not picking a specific number would be almost certain, but it is not impossible, because an argument for impossibility could be applied to any number.
For practical purposes, though, there is no difference between certain and almost certain.
Sourcepub fn never() -> Probability<T>
pub fn never() -> Probability<T>
The inverse of an “almost certain” condition (almost never).
Sourcepub fn half(self) -> Probability<T>
pub fn half(self) -> Probability<T>
Half the probability.
Sourcepub fn fifty() -> Probability<T>
pub fn fifty() -> Probability<T>
A fifty-fifty probability (0.5).
Sourcepub fn disjointed_or(self, rhs: Probability<T>) -> Probability<T>
pub fn disjointed_or(self, rhs: Probability<T>) -> Probability<T>
‘or’ for mutually exclusive events
Trait Implementations§
Source§impl<T: Num + PartialOrd> BitAnd for Probability<T>
impl<T: Num + PartialOrd> BitAnd for Probability<T>
Source§type Output = Probability<T>
type Output = Probability<T>
&
operator.Source§fn bitand(self, rhs: Probability<T>) -> Probability<T>
fn bitand(self, rhs: Probability<T>) -> Probability<T>
&
operation. Read moreSource§impl<T: Num + Clone + PartialOrd> BitOr for Probability<T>
impl<T: Num + Clone + PartialOrd> BitOr for Probability<T>
Source§type Output = Probability<T>
type Output = Probability<T>
|
operator.Source§fn bitor(self, rhs: Probability<T>) -> Probability<T>
fn bitor(self, rhs: Probability<T>) -> Probability<T>
|
operation. Read moreSource§impl<T: Num + Clone + PartialOrd> BitXor for Probability<T>
impl<T: Num + Clone + PartialOrd> BitXor for Probability<T>
Source§type Output = Probability<T>
type Output = Probability<T>
^
operator.Source§fn bitxor(self, rhs: Probability<T>) -> Probability<T>
fn bitxor(self, rhs: Probability<T>) -> Probability<T>
^
operation. Read moreSource§impl<T: Clone + Num> Clone for Probability<T>
impl<T: Clone + Num> Clone for Probability<T>
Source§fn clone(&self) -> Probability<T>
fn clone(&self) -> Probability<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T: Num + PartialOrd> Not for Probability<T>
impl<T: Num + PartialOrd> Not for Probability<T>
Source§type Output = Probability<T>
type Output = Probability<T>
!
operator.Source§fn not(self) -> Probability<T>
fn not(self) -> Probability<T>
!
operation. Read more