Struct stats_ci::quantile::Stats

source ·
pub struct Stats { /* private fields */ }
Expand description

Running statistics for quantiles

Implementations§

source§

impl Stats

source

pub fn new(population: usize) -> Self

Create a new instance with an initial population

source

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 level
  • quantile - 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 interval
  • InvalidQuantile - 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)?);
source

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 interval
  • InvalidQuantile - 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 Add<Stats> for Stats

§

type Output = Stats

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign<Stats> for Stats

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl Clone for Stats

source§

fn clone(&self) -> Stats

Returns a copy 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 Stats

source§

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

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

impl Default for Stats

source§

fn default() -> Stats

Returns the “default value” for a type. Read more
source§

impl Ord for Stats

source§

fn cmp(&self, other: &Stats) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Stats> for Stats

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Stats> for Stats

source§

fn partial_cmp(&self, other: &Stats) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Stats

source§

impl Eq for Stats

source§

impl StructuralEq for Stats

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
§

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

§

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

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

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

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

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

fn vzip(self) -> V

§

impl<T, Right> ClosedAdd<Right> for Twhere T: Add<Right, Output = T> + AddAssign<Right>,

source§

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