Struct bio::stats::probs::Prob[][src]

pub struct Prob(pub f64);

A newtype for probabilities.

Example

#[macro_use]
extern crate approx;
use bio::stats::Prob;

let p = Prob(0.5);
let q = Prob(0.2);

assert_relative_eq!(*(p + q), *Prob(0.7));

Implementations

impl Prob[src]

pub fn checked(p: f64) -> Result<Self>[src]

Methods from Deref<Target = f64>

pub const RADIX: u321.43.0[src]

pub const MANTISSA_DIGITS: u321.43.0[src]

pub const DIGITS: u321.43.0[src]

pub const EPSILON: f641.43.0[src]

pub const MIN: f641.43.0[src]

pub const MIN_POSITIVE: f641.43.0[src]

pub const MAX: f641.43.0[src]

pub const MIN_EXP: i321.43.0[src]

pub const MAX_EXP: i321.43.0[src]

pub const MIN_10_EXP: i321.43.0[src]

pub const MAX_10_EXP: i321.43.0[src]

pub const NAN: f641.43.0[src]

pub const INFINITY: f641.43.0[src]

pub const NEG_INFINITY: f641.43.0[src]

pub fn as_ne_bytes(&self) -> &[u8; 8][src]

🔬 This is a nightly-only experimental API. (num_as_ne_bytes)

Return the memory representation of this floating point number as a byte array in native byte order.

to_ne_bytes should be preferred over this whenever possible.

Examples

#![feature(num_as_ne_bytes)]
let num = 12.5f64;
let bytes = num.as_ne_bytes();
assert_eq!(
    bytes,
    if cfg!(target_endian = "big") {
        &[0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
    } else {
        &[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]
    }
);

pub fn total_cmp(&self, other: &f64) -> Ordering[src]

🔬 This is a nightly-only experimental API. (total_cmp)

Returns an ordering between self and other values. Unlike the standard partial comparison between floating point numbers, this comparison always produces an ordering in accordance to the totalOrder predicate as defined in IEEE 754 (2008 revision) floating point standard. The values are ordered in following order:

  • Negative quiet NaN
  • Negative signaling NaN
  • Negative infinity
  • Negative numbers
  • Negative subnormal numbers
  • Negative zero
  • Positive zero
  • Positive subnormal numbers
  • Positive numbers
  • Positive infinity
  • Positive signaling NaN
  • Positive quiet NaN

Note that this function does not always agree with the PartialOrd and PartialEq implementations of f64. In particular, they regard negative and positive zero as equal, while total_cmp doesn’t.

Example

#![feature(total_cmp)]
struct GoodBoy {
    name: String,
    weight: f64,
}

let mut bois = vec![
    GoodBoy { name: "Pucci".to_owned(), weight: 0.1 },
    GoodBoy { name: "Woofer".to_owned(), weight: 99.0 },
    GoodBoy { name: "Yapper".to_owned(), weight: 10.0 },
    GoodBoy { name: "Chonk".to_owned(), weight: f64::INFINITY },
    GoodBoy { name: "Abs. Unit".to_owned(), weight: f64::NAN },
    GoodBoy { name: "Floaty".to_owned(), weight: -5.0 },
];

bois.sort_by(|a, b| a.weight.total_cmp(&b.weight));

Trait Implementations

impl<'a> Add<&'a Prob> for &'a Prob[src]

type Output = Prob

The resulting type after applying the + operator.

impl<'a> Add<&'a Prob> for Prob[src]

type Output = Prob

The resulting type after applying the + operator.

impl Add<Prob> for Prob[src]

type Output = Prob

The resulting type after applying the + operator.

impl<'a> Add<Prob> for &'a Prob[src]

type Output = Prob

The resulting type after applying the + operator.

impl Clone for Prob[src]

impl Copy for Prob[src]

impl Debug for Prob[src]

impl Default for Prob[src]

impl Deref for Prob[src]

type Target = f64

The resulting type after dereferencing.

impl<'de> Deserialize<'de> for Prob[src]

impl<'a> Div<&'a Prob> for &'a Prob[src]

type Output = Prob

The resulting type after applying the / operator.

impl<'a> Div<&'a Prob> for Prob[src]

type Output = Prob

The resulting type after applying the / operator.

impl Div<Prob> for Prob[src]

type Output = Prob

The resulting type after applying the / operator.

impl<'a> Div<Prob> for &'a Prob[src]

type Output = Prob

The resulting type after applying the / operator.

impl From<LogProb> for Prob[src]

impl From<PHREDProb> for Prob[src]

impl From<Prob> for f64[src]

impl From<Prob> for LogProb[src]

impl From<Prob> for PHREDProb[src]

impl From<f64> for Prob[src]

impl<'a> Mul<&'a Prob> for &'a Prob[src]

type Output = Prob

The resulting type after applying the * operator.

impl<'a> Mul<&'a Prob> for Prob[src]

type Output = Prob

The resulting type after applying the * operator.

impl Mul<Prob> for Prob[src]

type Output = Prob

The resulting type after applying the * operator.

impl<'a> Mul<Prob> for &'a Prob[src]

type Output = Prob

The resulting type after applying the * operator.

impl PartialEq<Prob> for Prob[src]

impl PartialOrd<Prob> for Prob[src]

impl Serialize for Prob[src]

impl StructuralPartialEq for Prob[src]

impl<'a> Sub<&'a Prob> for &'a Prob[src]

type Output = Prob

The resulting type after applying the - operator.

impl<'a> Sub<&'a Prob> for Prob[src]

type Output = Prob

The resulting type after applying the - operator.

impl Sub<Prob> for Prob[src]

type Output = Prob

The resulting type after applying the - operator.

impl<'a> Sub<Prob> for &'a Prob[src]

type Output = Prob

The resulting type after applying the - operator.

impl Zero for Prob[src]

Auto Trait Implementations

impl RefUnwindSafe for Prob

impl Send for Prob

impl Sync for Prob

impl Unpin for Prob

impl UnwindSafe for Prob

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<M> Measure for M where
    M: Debug + PartialOrd<M> + Add<M, Output = M> + Default + Clone
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Debug + Any
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,