Trait net_ensembles::sampling::histogram::AtomicHistogramVal
source · [−]pub trait AtomicHistogramVal<T> {
fn get_bin_index<V>(&self, val: V) -> Result<usize, HistErrors>
where
V: Borrow<T>;
fn count_val<V>(&self, val: V) -> Result<usize, HistErrors>
where
V: Borrow<T>;
fn borders_clone(&self) -> Result<Vec<T, Global>, HistErrors>;
fn is_inside<V>(&self, val: V) -> bool
where
V: Borrow<T>;
fn not_inside<V>(&self, val: V) -> bool
where
V: Borrow<T>;
fn first_border(&self) -> T;
fn second_last_border(&self) -> T;
fn distance<V>(&self, val: V) -> f64
where
V: Borrow<T>;
}
Expand description
- trait used for mapping values of arbitrary type
T
to bins - used to create a histogram
Required Methods
sourcefn get_bin_index<V>(&self, val: V) -> Result<usize, HistErrors>where
V: Borrow<T>,
fn get_bin_index<V>(&self, val: V) -> Result<usize, HistErrors>where
V: Borrow<T>,
convert val to the respective histogram index
sourcefn count_val<V>(&self, val: V) -> Result<usize, HistErrors>where
V: Borrow<T>,
fn count_val<V>(&self, val: V) -> Result<usize, HistErrors>where
V: Borrow<T>,
count val. Ok(index)
, if inside of hist, Err(_)
if val is invalid
sourcefn borders_clone(&self) -> Result<Vec<T, Global>, HistErrors>
fn borders_clone(&self) -> Result<Vec<T, Global>, HistErrors>
binning borders
- the borders used to bin the values
- any val which fullfills
self.border[i] <= val < self.border[i + 1]
will get indexi
. - Note that the last border is exclusive
sourcefn is_inside<V>(&self, val: V) -> boolwhere
V: Borrow<T>,
fn is_inside<V>(&self, val: V) -> boolwhere
V: Borrow<T>,
does a value correspond to a valid bin?
sourcefn not_inside<V>(&self, val: V) -> boolwhere
V: Borrow<T>,
fn not_inside<V>(&self, val: V) -> boolwhere
V: Borrow<T>,
opposite of is_inside
sourcefn first_border(&self) -> T
fn first_border(&self) -> T
get the left most border (inclusive)
sourcefn second_last_border(&self) -> T
fn second_last_border(&self) -> T
- get second last border from the right
- should be the same as
let b = self.borders_clone().expect("overflow"); assert_eq!(self.second_last_border(), b[b.len()-2])
sourcefn distance<V>(&self, val: V) -> f64where
V: Borrow<T>,
fn distance<V>(&self, val: V) -> f64where
V: Borrow<T>,
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