pub struct Histogram<T>{ /* private fields */ }
Expand description
The Histogram consists of num_intervals
intervals between the min
and
the max
value.
Implementations§
source§impl<T> Histogram<T>
impl<T> Histogram<T>
sourcepub fn new<'a>(
elements: Option<&'a Vec<T>>,
num_intervals: usize,
min: T,
max: T
) -> Result<Histogram<T>, String>
pub fn new<'a>( elements: Option<&'a Vec<T>>, num_intervals: usize, min: T, max: T ) -> Result<Histogram<T>, String>
Initializing with Known Boundaries
Creates a Histogram consisting of num_intervals
intervals between the
values min
and max
, and inserts the values from the vector of
elements
into the histogram. Values smaller than min
will
increment the counter num_less_than_min
, while values larger than
max
will increment the counter num_larger_than_max
Example
use math::histogram::Histogram;
let histogram =
Histogram::new(Some(&vec![2, -1, 3, 5, 8]), 5, 0, 10).unwrap();
assert_eq!(histogram.get_boundaries().len(), 6);
assert_eq!(histogram.get_num_less_than_min(), 1);
assert_eq!(histogram.get_num_larger_than_max(), 0);
assert_eq!(histogram.get_min_received(), Some(-1));
assert_eq!(histogram.get_max_received(), Some(8));
pub fn num_intervals(&self) -> usize
pub fn get_ratios(&self) -> Vec<f64>
pub fn new_with_auto_range<'a>( elements: &'a Vec<T>, num_intervals: usize ) -> Result<Histogram<T>, String>
pub fn get_boundaries(&self) -> &Vec<T>
pub fn get_counters(&self) -> &Vec<usize>
pub fn get_num_less_than_min(&self) -> usize
pub fn get_num_larger_than_max(&self) -> usize
pub fn get_min_received(&self) -> Option<T>
pub fn get_max_received(&self) -> Option<T>
pub fn min_boundary(&self) -> T
pub fn max_boundary(&self) -> T
Trait Implementations§
source§impl<T> Collecting<T> for Histogram<T>
impl<T> Collecting<T> for Histogram<T>
source§impl<T> PartialEq for Histogram<T>where
T: PartialOrd + NumAssign + NumOps + FromPrimitive + ToPrimitive + Copy + Display + PartialEq,
impl<T> PartialEq for Histogram<T>where
T: PartialOrd + NumAssign + NumOps + FromPrimitive + ToPrimitive + Copy + Display + PartialEq,
source§impl<'a, T> ToIterator<'a, HistogramIter<'a, T>, (T, T, usize)> for Histogram<T>
impl<'a, T> ToIterator<'a, HistogramIter<'a, T>, (T, T, usize)> for Histogram<T>
fn to_iter(&'a self) -> HistogramIter<'a, T> ⓘ
impl<T> Eq for Histogram<T>
impl<T> StructuralEq for Histogram<T>
impl<T> StructuralPartialEq for Histogram<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Histogram<T>where
T: RefUnwindSafe,
impl<T> Send for Histogram<T>where
T: Send,
impl<T> Sync for Histogram<T>where
T: Sync,
impl<T> Unpin for Histogram<T>where
T: Unpin,
impl<T> UnwindSafe for Histogram<T>where
T: UnwindSafe,
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