Skip to main content

ConfidenceLevel

Struct ConfidenceLevel 

Source
pub struct ConfidenceLevel<T>(/* private fields */);
Expand description

A statistical confidence level.

Represents a probability in the closed interval [0, 1].

Common values include:

  • 0.90 (90%)
  • 0.95 (95%)
  • 0.99 (99%)

A confidence level c corresponds to a significance level α = 1 - c.

Implementations§

Source§

impl ConfidenceLevel<f32>

Source

pub const CL90: Self

Source

pub const CL95: Self

Source

pub const CL975: Self

Source

pub const CL99: Self

Source

pub const CL999: Self

Source§

impl ConfidenceLevel<f64>

Source

pub const CL90: Self

Source

pub const CL95: Self

Source

pub const CL975: Self

Source

pub const CL99: Self

Source

pub const CL999: Self

Source§

impl<T> ConfidenceLevel<T>

Source

pub fn into_inner(self) -> T

Returns the probability associated with the confidence level

Source§

impl<T: Float> ConfidenceLevel<T>

Source

pub fn new(probability: T) -> Result<Self, ValidationError>

Creates a confidence level from a probability.

§Examples
use confi::ConfidenceLevel;

let cl = ConfidenceLevel::new(0.95)?;
assert_eq!(cl.into_inner(), 0.95);
§Errors
  • If the provided probability is outside [0, 1]
  • If the provided probability is NaN
Source

pub fn significance(self) -> SignificanceLevel<T>

Convert to the associated significance level

As confidence levels are checked for validity on creation the conversion is infallible

§Examples
use confi::ConfidenceLevel;

let cl = ConfidenceLevel::new(0.95)?;
let significance = cl.significance();
approx::assert_relative_eq!(significance.into_inner(), 0.05);
Source§

impl<T: Float + FromPrimitive> ConfidenceLevel<T>

Source

pub fn from_percent(percentage: T) -> Result<Self, ValidationError>

Creates a confidence level from a percentage.

§Examples
use confi::ConfidenceLevel;

let cl = ConfidenceLevel::from_percent(95.0)?;
assert_eq!(cl.into_inner(), 0.95);
§Errors
  • If the provided percentage is outside [0, 100]
  • If the provided percentage is NaN
Source§

impl<T: ToPrimitive> ConfidenceLevel<T>

Trait Implementations§

Source§

impl<T: Clone> Clone for ConfidenceLevel<T>

Source§

fn clone(&self) -> ConfidenceLevel<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Copy> Copy for ConfidenceLevel<T>

Source§

impl<T: Debug> Debug for ConfidenceLevel<T>

Source§

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

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

impl<T: ToPrimitive> Display for ConfidenceLevel<T>

Source§

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

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

impl<T: Float> From<ConfidenceLevel<T>> for SignificanceLevel<T>

Source§

fn from(confidence_level: ConfidenceLevel<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Float> From<SignificanceLevel<T>> for ConfidenceLevel<T>

Source§

fn from(significance_level: SignificanceLevel<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: PartialEq> PartialEq for ConfidenceLevel<T>

Source§

fn eq(&self, other: &ConfidenceLevel<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<T: PartialOrd> PartialOrd for ConfidenceLevel<T>

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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<T: PartialEq> StructuralPartialEq for ConfidenceLevel<T>

Auto Trait Implementations§

§

impl<T> Freeze for ConfidenceLevel<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ConfidenceLevel<T>
where T: RefUnwindSafe,

§

impl<T> Send for ConfidenceLevel<T>
where T: Send,

§

impl<T> Sync for ConfidenceLevel<T>
where T: Sync,

§

impl<T> Unpin for ConfidenceLevel<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for ConfidenceLevel<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for ConfidenceLevel<T>
where T: UnwindSafe,

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.