pub struct ConfidenceInterval<T> { /* private fields */ }Expand description
A statistical confidence interval.
A confidence interval represents a bounded range of values associated with a statistical estimate, together with a confidence level describing the reliability of the construction procedure.
§Structure
A confidence interval consists of:
- a lower bound
- an upper bound
- an associated
ConfidenceLevel
§Geometry
The interval is closed:
lower ≤ x ≤ upperImplementations§
Source§impl<T: Copy> ConfidenceInterval<T>
impl<T: Copy> ConfidenceInterval<T>
Sourcepub fn level(&self) -> ConfidenceLevel<T>
pub fn level(&self) -> ConfidenceLevel<T>
Returns the confidence level associated with the confidence interval
Source§impl<T: Float> ConfidenceInterval<T>
impl<T: Float> ConfidenceInterval<T>
Sourcepub fn new(
lower: T,
upper: T,
confidence_level: ConfidenceLevel<T>,
) -> Result<Self, ValidationError>
pub fn new( lower: T, upper: T, confidence_level: ConfidenceLevel<T>, ) -> Result<Self, ValidationError>
Creates a confidence interval from a lower and upper bounds and a confidence level.
§Examples
use confi::{ConfidenceInterval, ConfidenceLevel};
let cl = ConfidenceLevel::new(0.95)?;
let (lower, upper) = (0.0, 1.0);
let ci = ConfidenceInterval::new(lower, upper, cl)?;
assert_eq!(ci.lower(), lower);
assert_eq!(ci.upper(), upper);
assert_eq!(ci.level().into_inner(), 0.95);§Errors
- If the lower or upper bound are NaN
- If the lower or upper bound are infinite
- If the lower or upper bound do not form an ordered interval
Source§impl<T: Float> ConfidenceInterval<T>
impl<T: Float> ConfidenceInterval<T>
Source§impl<T: Float> ConfidenceInterval<T>
impl<T: Float> ConfidenceInterval<T>
Sourcepub fn contains(&self, value: T) -> bool
pub fn contains(&self, value: T) -> bool
Returns true if the interval contains the argument
§Examples
use confi::{ConfidenceInterval, ConfidenceLevel};
let cl = ConfidenceLevel::new(0.95)?;
let (lower, upper) = (0.0, 1.0);
let ci = ConfidenceInterval::new(lower, upper, cl)?;
assert_eq!(ci.contains(0.5), true);
assert_eq!(ci.contains(1.5), false);Sourcepub fn width(&self) -> T
pub fn width(&self) -> T
Returns the width of the confidence interval
§Examples
use confi::{ConfidenceInterval, ConfidenceLevel};
let cl = ConfidenceLevel::new(0.95)?;
let (lower, upper) = (0.0, 1.0);
let ci = ConfidenceInterval::new(lower, upper, cl)?;
assert_eq!(ci.width(), upper - lower);Source§impl<T> ConfidenceInterval<T>where
T: ToPrimitive,
impl<T> ConfidenceInterval<T>where
T: ToPrimitive,
pub fn to_f64(self) -> Option<ConfidenceInterval<f64>>
pub fn to_f32(self) -> Option<ConfidenceInterval<f32>>
Trait Implementations§
Source§impl<T: Clone> Clone for ConfidenceInterval<T>
impl<T: Clone> Clone for ConfidenceInterval<T>
Source§fn clone(&self) -> ConfidenceInterval<T>
fn clone(&self) -> ConfidenceInterval<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for ConfidenceInterval<T>
impl<T: Debug> Debug for ConfidenceInterval<T>
Auto Trait Implementations§
impl<T> Freeze for ConfidenceInterval<T>where
T: Freeze,
impl<T> RefUnwindSafe for ConfidenceInterval<T>where
T: RefUnwindSafe,
impl<T> Send for ConfidenceInterval<T>where
T: Send,
impl<T> Sync for ConfidenceInterval<T>where
T: Sync,
impl<T> Unpin for ConfidenceInterval<T>where
T: Unpin,
impl<T> UnsafeUnpin for ConfidenceInterval<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for ConfidenceInterval<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more