HistogramVal

Trait HistogramVal 

Source
pub trait HistogramVal<T> {
    // Required methods
    fn get_bin_index<V: Borrow<T>>(&self, val: V) -> Result<usize, HistErrors>;
    fn count_val<V: Borrow<T>>(&mut self, val: V) -> Result<usize, HistErrors>;
    fn bin_enum_iter(&self) -> Box<dyn Iterator<Item = Bin<T>> + '_>;
    fn is_inside<V: Borrow<T>>(&self, val: V) -> bool;
    fn not_inside<V: Borrow<T>>(&self, val: V) -> bool;
    fn first_border(&self) -> T;
    fn last_border(&self) -> T;
    fn last_border_is_inclusive(&self) -> bool;
    fn distance<V: Borrow<T>>(&self, val: V) -> f64;
}
Expand description
  • trait used for mapping values of arbitrary type T to bins
  • used to create a histogram

Required Methods§

Source

fn get_bin_index<V: Borrow<T>>(&self, val: V) -> Result<usize, HistErrors>

convert val to the respective histogram index

Source

fn count_val<V: Borrow<T>>(&mut self, val: V) -> Result<usize, HistErrors>

count val. Ok(index), if inside of hist, Err(_) if val is invalid

Source

fn bin_enum_iter(&self) -> Box<dyn Iterator<Item = Bin<T>> + '_>

§binning borders
  • the borders used to bin the values
Source

fn is_inside<V: Borrow<T>>(&self, val: V) -> bool

does a value correspond to a valid bin?

Source

fn not_inside<V: Borrow<T>>(&self, val: V) -> bool

opposite of is_inside

Source

fn first_border(&self) -> T

get the left most border (inclusive)

Source

fn last_border(&self) -> T

§get last border from the right
  • Note: this border might be inclusive or exclusive
  • check last_border_is_inclusive for finding it out
Source

fn last_border_is_inclusive(&self) -> bool

§True if last border is inclusive, false otherwise
  • For most usecases this will return a constant value, as this is likely only dependent on the underlying type and not on something that changes dynamically
Source

fn distance<V: Borrow<T>>(&self, val: V) -> f64

§calculates some sort of absolute distance to the nearest valid bin
  • any invalid numbers (like NAN or INFINITY) should have the highest distance possible
  • if a value corresponds to a valid bin, the distance should be zero

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> HistogramVal<T> for HistogramFast<T>

Source§

impl<T> HistogramVal<T> for HistogramFloat<T>

Source§

impl<T> HistogramVal<T> for HistogramInt<T>
where T: Ord + Sub<T, Output = T> + Add<T, Output = T> + One + NumCast + Copy,

Source§

impl<T, B> HistogramVal<T> for GenericHist<B, T>
where B: Binning<T>,