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

Object Safety§

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>,