Struct Histogram

Source
pub struct Histogram { /* private fields */ }
Expand description

Histogram used as the basis for statistics counting in many quality control facets. For more in depth information, please see the module-level documentation.

Implementations§

Source§

impl Histogram

Source

pub fn zero_based_with_capacity(capacity: usize) -> Self

Creates a zero-based histogram with a given capacity.

Source

pub fn increment(&mut self, bin: usize) -> Result<(), BinOutOfBoundsError>

Increments a particular bin in the histogram by one.

Source

pub fn increment_by( &mut self, bin: usize, value: usize, ) -> Result<(), BinOutOfBoundsError>

Increments a particular bin in the histogram by the specified value.

Source

pub fn get(&self, bin: usize) -> usize

Gets a value for a bin within a histogram.

Source

pub fn values(&self) -> &[usize]

Simply returns the values in the distribution by ref.

Source

pub fn values_normalized(&self) -> Vec<f64>

Normalizes the values so that they sum to one and returns them as a Vec.

Source

pub fn range_len(&self) -> usize

Gives the length of the open range for the histogram.

Source

pub fn range_start(&self) -> usize

Gives the starting position for the open range of the histogram.

Source

pub fn range_stop(&self) -> usize

Gives the stopping position for the open range of the histogram.

Source

pub fn in_range(&self, value: usize) -> bool

Indicates whether a particular value falls within the range of the histogram.

use ngs::utils::histogram::Histogram;
let mut hist = Histogram::zero_based_with_capacity(100);

assert!(hist.in_range(0));
assert!(hist.in_range(100));
assert!(!hist.in_range(101));
Source

pub fn mean(&self) -> f64

Computes the mean of all values within the histogram.

Source

pub fn percentile(&self, percentile: f64) -> Result<Option<f64>>

Computes the value of the nth percentile based on an exhaustive search.

Source

pub fn first_quartile(&self) -> Option<f64>

Computes the first quartile of the distribution.

Source

pub fn median(&self) -> Option<f64>

Computes the mean of the distribution.

Source

pub fn third_quartile(&self) -> Option<f64>

Computes the third quartile of the distribution.

Source

pub fn interquartile_range(&self) -> Option<f64>

Computes the interquartile range for this distribution.

Source

pub fn sum(&self) -> usize

Computes the sum of the values within the distribution.

Source

pub fn count_from_bottom_until(&self, bin: usize) -> usize

Counts from the bottom of the histogram up until a certain bin.

Source

pub fn count_from_top_until(&self, bin: usize) -> usize

Counts from the top of the histogram down until a certain bin.

More accurately, we technically walk from the specified bin up to the top of the histogram, but this provides the same results.

Trait Implementations§

Source§

impl Clone for Histogram

Source§

fn clone(&self) -> Histogram

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Histogram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Histogram

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Histogram

Source§

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 Serialize for Histogram

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,