cert

Trait Uncertainty

Source
pub trait Uncertainty:
    Sized
    + Copy
    + Into<AbsUncertainty<Self::Float>>
    + Into<RelUncertainty<Self::Float>>
    + Add<Self, Output = Self>
    + Div<Self, Output = Self>
    + Mul<Self, Output = Self>
    + Sub<Self, Output = Self>
    + Zero {
    type Float: Float + Zero;

    // Required methods
    fn new(value: Self::Float, uncertainty: Self::Float) -> Self;
    fn mean(&self) -> Self::Float;
    fn standard_deviation(&self) -> Self::Float;
    fn coefficient_of_variation(&self) -> Self::Float;
    fn uncertainty(&self) -> Self::Float;

    // Provided methods
    fn is_certain(&self) -> bool { ... }
    fn powi(&self, n: i32) -> Self { ... }
}
Expand description

Used to define behaviour for values which have associated uncertainty.

Required Associated Types§

Source

type Float: Float + Zero

The underlying float type for the uncertainty

Required Methods§

Source

fn new(value: Self::Float, uncertainty: Self::Float) -> Self

Source

fn mean(&self) -> Self::Float

Returns the mean of the value

Source

fn standard_deviation(&self) -> Self::Float

The standard deviation of the value

Source

fn coefficient_of_variation(&self) -> Self::Float

The coefficient of variation is the ratio of the standard deviation and the mean.

It describes the relative error.

Source

fn uncertainty(&self) -> Self::Float

The actual uncertainty of the concrete type. This will depend on whether the implementor represent a relative or absolute uncertainty.

Provided Methods§

Source

fn is_certain(&self) -> bool

Returns true if the uncertainty is zero.

This method is useful when the type may be used in a method which divides by the uncertainties.

Source

fn powi(&self, n: i32) -> Self

Raise the value to the nth power.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Uncertainty for f64

Source§

type Float = f64

Source§

fn new(value: f64, _uncertainty: f64) -> f64

Source§

fn mean(&self) -> Self::Float

Source§

fn standard_deviation(&self) -> Self::Float

Source§

fn coefficient_of_variation(&self) -> Self::Float

Source§

fn uncertainty(&self) -> Self::Float

Source§

fn is_certain(&self) -> bool

Source§

fn powi(&self, n: i32) -> Self

Implementors§