Confidence

Enum Confidence 

Source
pub enum Confidence {
    TwoSided(f64),
    UpperOneSided(f64),
    LowerOneSided(f64),
}
Expand description

Confidence level of a confidence interval.

§Operations

§Creation

§Accessors

  • Confidence::level - return the confidence level of the interval as a number in the range (0, 1)
  • Confidence::percent - return the confidence level of the interval as a percentage
  • Confidence::kind - return the kind of the confidence interval as a string (in English)

§Characteristics

§Conversions

  • Confidence::flipped - return the confidence interval with the same confidence level but flipped (e.g., upper to lower)

§Comparison

Confidence implements PartialOrd where some confidence a is less than some confidence b if they are of the same kind and the confidence level of a is less than the confidence level of b.

§Examples

§Creation

To create a two-sided confidence interval with 95% confidence:

let confidence = Confidence::new_two_sided(0.95);
// alternatively:
let confidence = Confidence::new(0.95);

To create an upper one-sided confidence interval with 90% confidence:

let confidence = Confidence::new_upper(0.9);

To create a lower one-sided confidence interval with 99% confidence:

let confidence = Confidence::new_lower(0.99);

§Accessors

The confidence object provides several accessors:

let confidence = Confidence::new(0.95);
assert_eq!(confidence.level(), 0.95);
assert_eq!(confidence.percent(), 95.);
assert_eq!(confidence.kind(), "two-sided");
assert!(confidence.is_two_sided());
assert!(!confidence.is_one_sided());
assert!(!confidence.is_upper());
assert!(!confidence.is_lower());

§Conversions

let confidence = Confidence::new_upper(0.95);
assert_eq!(confidence.flipped(), Confidence::new_lower(0.95));

§Comparison

let confidence = Confidence::new(0.95);
assert!(confidence > Confidence::new(0.9));
assert!(confidence < Confidence::new(0.99));

Variants§

§

TwoSided(f64)

Confidence for a two-sided interval.

§

UpperOneSided(f64)

Confidence for an upper one-sided interval.

§

LowerOneSided(f64)

Confidence for a lower one-sided interval.

Implementations§

Source§

impl Confidence

Source

pub fn new(confidence: f64) -> Self

Create a new two-sided confidence interval with the given confidence level. This is the same as Confidence::new_two_sided.

§Arguments
  • confidence - the confidence level, e.g. 0.95 for 95% confidence
§Panics
  • if confidence is not in the range (0, 1)
Source

pub fn new_two_sided(confidence: f64) -> Self

Create a new two-sided confidence interval with the given confidence level.

§Arguments
  • confidence - the confidence level, e.g. 0.95 for 95% confidence
§Panics
  • if confidence is not in the range (0, 1)
Source

pub fn new_upper(confidence: f64) -> Self

Create a new one-sided upper confidence interval with the given confidence level.

§Arguments
  • confidence - the confidence level, e.g. 0.95 for 95% confidence
§Panics
  • if confidence is not in the range (0, 1)
Source

pub fn new_lower(confidence: f64) -> Self

Create a new one-sided lower confidence interval with the given confidence level.

§Arguments
  • confidence - the confidence level, e.g. 0.95 for 95% confidence
§Panics
  • if confidence is not in the range (0, 1)
Source

pub fn level(&self) -> f64

Return the confidence level of the interval as a number in the range (0, 1).

Source

pub fn percent(&self) -> f64

Return the confidence level of the interval as a percentage.

Source

pub fn kind(&self) -> &'static str

Return the kind of the confidence interval as a string (in English).

Source

pub fn is_two_sided(&self) -> bool

Test if the confidence interval is two-sided.

Source

pub fn is_one_sided(&self) -> bool

Test if the confidence interval is one-sided.

Source

pub fn is_upper(&self) -> bool

Test if the confidence interval is upper (one-sided).

Source

pub fn is_lower(&self) -> bool

Test if the confidence interval is lower (one-sided).

Source

pub fn flipped(&self) -> Self

Return the confidence interval with the same confidence level but flipped. For a two-sided interval, this is the same interval. For a one-sided interval, this is the interval with the opposite direction. For example, a lower one-sided interval with confidence 0.95 flipped is an upper one-sided interval with confidence 0.95.

Trait Implementations§

Source§

impl Clone for Confidence

Source§

fn clone(&self) -> Confidence

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Confidence

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Confidence

Source§

fn default() -> Self

Create a new two-sided confidence interval with the default confidence level of 95%.

Source§

impl PartialEq for Confidence

Source§

fn eq(&self, other: &Confidence) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Confidence

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFrom<f32> for Confidence

Source§

type Error = CIError

The type returned in the event of a conversion error.
Source§

fn try_from(confidence: f32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<f64> for Confidence

Source§

type Error = CIError

The type returned in the event of a conversion error.
Source§

fn try_from(confidence: f64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Confidence

Source§

impl StructuralPartialEq for Confidence

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,