Skip to main content

Histogram

Struct Histogram 

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

The histogram will take incoming data, place it into discrete bins, and count the hits in each bin The bin_labels are labeled by the minimum boundary of the bin e.g. bin_value = 1, with a bin width of 1, corresponds to hits in the interval [1,2).

Implementations§

Source§

impl Histogram

Source

pub fn new(bin_min: f64, bin_max: f64, n_bins: usize) -> Self

Creates a new histogram that spans [bin_min, bin_max] with n_bins equal bins. The bin labels are the lower edges, bin_min + i · width; bin_max itself is counted in the last bin.

Source

pub fn reset(&mut self)

Reset the counts in each bin

Source

pub fn count(&mut self, value: f64) -> Result<(), ErrorsJSL>

Find the bin of the value and increment the count Will fail if the sample exceeds the bin_min and bin_max

Source

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

Getters

Source

pub fn get_counts_raw(&self) -> &Vec<usize>

Get counts without dividing by total

Source

pub fn get_counts_normalized(&self) -> Result<Vec<f64>, ErrorsJSL>

Get counts after dividing by total. Will fail if total = 0;

Source

pub fn get_total(&self) -> usize

Get the total

Source

pub fn get_bin_width(&self) -> f64

Get the bin width

Source

pub fn get_counts_raw_paired(&self) -> Vec<(f64, usize)>

These functions return vectors of tuples (bin_label,count) In either raw or normalized format

Source

pub fn get_counts_normalized_paired(&self) -> Result<Vec<(f64, f64)>, ErrorsJSL>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.