Struct average::Histogram10
source · pub struct Histogram10 { /* private fields */ }Expand description
A histogram with a number of bins known at compile time.
Implementations§
source§impl Histogram
impl Histogram
sourcepub fn with_const_width(start: f64, end: f64) -> Self
pub fn with_const_width(start: f64, end: f64) -> Self
Construct a histogram with constant bin width.
sourcepub fn from_ranges<T>(ranges: T) -> Result<Self, InvalidRangeError>where
T: IntoIterator<Item = f64>,
pub fn from_ranges<T>(ranges: T) -> Result<Self, InvalidRangeError>where T: IntoIterator<Item = f64>,
Construct a histogram from given ranges.
The ranges are given by an iterator of floats where neighboring
pairs (a, b) define a bin for all x where a <= x < b.
Fails if the iterator is too short (less than n + 1 where n
is the number of bins), is not sorted or contains nan. inf
and empty ranges are allowed.
sourcepub fn find(&self, x: f64) -> Result<usize, SampleOutOfRangeError>
pub fn find(&self, x: f64) -> Result<usize, SampleOutOfRangeError>
Find the index of the bin corresponding to the given sample.
Fails if the sample is out of range of the histogram.
sourcepub fn add(&mut self, x: f64) -> Result<(), SampleOutOfRangeError>
pub fn add(&mut self, x: f64) -> Result<(), SampleOutOfRangeError>
Add a sample to the histogram.
Fails if the sample is out of range of the histogram.
sourcepub fn iter(&self) -> IterHistogram<'_>
pub fn iter(&self) -> IterHistogram<'_>
Return an iterator over the bins and corresponding ranges:
((lower, upper), count)
Trait Implementations§
source§impl<'a> AddAssign<&'a Histogram> for Histogram
impl<'a> AddAssign<&'a Histogram> for Histogram
source§fn add_assign(&mut self, other: &Self)
fn add_assign(&mut self, other: &Self)
Performs the
+= operation. Read moresource§impl<'de> Deserialize<'de> for Histogram
impl<'de> Deserialize<'de> for Histogram
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Histogram for Histogram
impl Histogram for Histogram
source§fn normalized_bins(&self) -> IterNormalized<<&Self as IntoIterator>::IntoIter>
fn normalized_bins(&self) -> IterNormalized<<&Self as IntoIterator>::IntoIter>
Return an iterator over the bins normalized by the bin widths.
source§fn widths(&self) -> IterWidths<<&Self as IntoIterator>::IntoIter>
fn widths(&self) -> IterWidths<<&Self as IntoIterator>::IntoIter>
Return an iterator over the bin widths.
source§impl<'a> IntoIterator for &'a Histogram
impl<'a> IntoIterator for &'a Histogram
Auto Trait Implementations§
impl RefUnwindSafe for Histogram
impl Send for Histogram
impl Sync for Histogram
impl Unpin for Histogram
impl UnwindSafe for Histogram
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
source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere T: ConvApprox<S>,
source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere T: ConvFloat<S>,
source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more