pub struct Stats { /* private fields */ }Expand description
Running statistics for quantiles
Implementations§
source§impl Stats
impl Stats
sourcepub fn ci(
&self,
confidence: Confidence,
quantile: f64
) -> CIResult<Interval<usize>>
pub fn ci( &self, confidence: Confidence, quantile: f64 ) -> CIResult<Interval<usize>>
Return the confidence interval on the indices for a given quantile.
Arguments
confidence- the confidence levelquantile- the quantile (must be in the range [0, 1])
Returns
A confidence interval containing indices on the corresponding data.
Errors
TooFewSamples- if the number of samples is too small to compute a confidence intervalInvalidQuantile- if the quantile is not in the range [0, 1]IndexError- if the confidence interval falls outside the range of the data
Examples
let data = [1, 2, 3, 4, 5, 6, 7, 8, 9];
let confidence = Confidence::new_two_sided(0.8);
let quantile = 0.5; // median
let stats = quantile::Stats::new(data.len());
let interval = stats.ci(confidence, quantile)?;
assert_eq!(interval, Interval::new(3, 6)?);sourcepub fn index(&self, quantile: f64) -> CIResult<usize>
pub fn index(&self, quantile: f64) -> CIResult<usize>
Return the index for a given quantile.
Arguments
quantile- the quantile (must be in the range [0, 1])
Returns
The index corresponding to the quantile.
Errors
TooFewSamples- if the number of samples is too small to compute a confidence intervalInvalidQuantile- if the quantile is not in (0, 1)
Examples
let data = ['a', 'b', 'c', 'd', 'e'];
let stats = quantile::Stats::new(data.len());
assert_eq!(stats.index(0.).unwrap(), 0);
assert_eq!(stats.index(0.5).unwrap(), 2);
assert_eq!(stats.index(1.).unwrap(), 4);
assert_eq!(data[stats.index(0.25).unwrap()], 'b');
assert_eq!(data[stats.index(0.75).unwrap()], 'd');Trait Implementations§
source§impl AddAssign<Stats> for Stats
impl AddAssign<Stats> for Stats
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moresource§impl Ord for Stats
impl Ord for Stats
source§impl PartialEq<Stats> for Stats
impl PartialEq<Stats> for Stats
source§impl PartialOrd<Stats> for Stats
impl PartialOrd<Stats> for Stats
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Copy for Stats
impl Eq for Stats
impl StructuralEq for Stats
impl StructuralPartialEq for Stats
Auto Trait Implementations§
impl RefUnwindSafe for Stats
impl Send for Stats
impl Sync for Stats
impl Unpin for Stats
impl UnwindSafe for Stats
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
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.