pub enum Confidence {
TwoSided(f64),
UpperOneSided(f64),
LowerOneSided(f64),
}Expand description
Confidence level of a confidence interval.
§Operations
§Creation
Confidence::new- create a new two-sided confidence interval with the given confidence levelConfidence::new_two_sided- idemConfidence::new_upper- create a new one-sided upper confidence interval with the given confidence levelConfidence::new_lower- create a new one-sided lower confidence interval with the given confidence level
§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 percentageConfidence::kind- return the kind of the confidence interval as a string (in English)
§Characteristics
Confidence::is_two_sided- test if the confidence interval is two-sidedConfidence::is_one_sided- test if the confidence interval is one-sidedConfidence::is_upper- test if the confidence interval is upper (one-sided)Confidence::is_lower- test if the confidence interval is lower (one-sided)
§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
impl Confidence
Sourcepub fn new(confidence: f64) -> Self
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
confidenceis not in the range (0, 1)
Sourcepub fn new_two_sided(confidence: f64) -> Self
pub fn new_two_sided(confidence: f64) -> Self
Sourcepub fn level(&self) -> f64
pub fn level(&self) -> f64
Return the confidence level of the interval as a number in the range (0, 1).
Sourcepub fn kind(&self) -> &'static str
pub fn kind(&self) -> &'static str
Return the kind of the confidence interval as a string (in English).
Sourcepub fn is_two_sided(&self) -> bool
pub fn is_two_sided(&self) -> bool
Test if the confidence interval is two-sided.
Sourcepub fn is_one_sided(&self) -> bool
pub fn is_one_sided(&self) -> bool
Test if the confidence interval is one-sided.
Sourcepub fn flipped(&self) -> Self
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
impl Clone for Confidence
Source§fn clone(&self) -> Confidence
fn clone(&self) -> Confidence
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Confidence
impl Debug for Confidence
Source§impl Default for Confidence
impl Default for Confidence
Source§impl PartialEq for Confidence
impl PartialEq for Confidence
Source§impl PartialOrd for Confidence
impl PartialOrd for Confidence
Source§impl TryFrom<f32> for Confidence
impl TryFrom<f32> for Confidence
Source§impl TryFrom<f64> for Confidence
impl TryFrom<f64> for Confidence
impl Copy for Confidence
impl StructuralPartialEq for Confidence
Auto Trait Implementations§
impl Freeze for Confidence
impl RefUnwindSafe for Confidence
impl Send for Confidence
impl Sync for Confidence
impl Unpin for Confidence
impl UnwindSafe for Confidence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.