Struct prob::Probability [] [src]

pub struct Probability<T: Num>(pub T);

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.

Methods

impl<T: Num + PartialOrd> Probability<T>
[src]

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.

The inverse of an "almost certain" condition (almost never).

Half the probability.

A fifty-fifty probability (0.5).

'or' for mutually exclusive events

Trait Implementations

impl<T: Copy + Num> Copy for Probability<T>
[src]

impl<T: Clone + Num> Clone for Probability<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: PartialEq + Num> PartialEq for Probability<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: Eq + Num> Eq for Probability<T>
[src]

impl<T: Debug + Num> Debug for Probability<T>
[src]

Formats the value using the given formatter.

impl<T: PartialOrd + Num> PartialOrd for Probability<T>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T: Ord + Num> Ord for Probability<T>
[src]

This method returns an Ordering between self and other. Read more

impl<T: Num + PartialOrd> Not for Probability<T>
[src]

The resulting type after applying the ! operator

The method for the unary ! operator

impl<T: Num + PartialOrd> BitAnd for Probability<T>
[src]

The resulting type after applying the & operator

The method for the & operator

impl<T: Num + Clone + PartialOrd> BitOr for Probability<T>
[src]

The resulting type after applying the | operator

The method for the | operator

impl<T: Num + Clone + PartialOrd> BitXor for Probability<T>
[src]

The resulting type after applying the ^ operator

The method for the ^ operator