[][src]Struct ndhistogram::value::WeightedMean

pub struct WeightedMean<T = f64, W = f64, O = f64, C = u32> { /* fields omitted */ }

ndhistogram bin value computes the mean of the data samples provided when filling.

Mean has 4 type parameters:

  • the type that is being averaged,
  • the type of the weights that are being filled,
  • the type of the output when calculating the mean and its uncertainty,
  • the type that counts the number of fills.

This allows, for example, integers to be used when filling or counting, but a floating point type to compute the mean. In most cases, you will only need to specify the first two type parameters as sensible defaults are set for the second two type parameters.

Example

use ndhistogram::{ndhistogram, Histogram, axis::Uniform, value::WeightedMean};

// create a histogram and fill it with some values
let mut hist = ndhistogram!(Uniform::new(10, 0.0, 10.0); WeightedMean<i32, i32>);
hist.fill_with_weighted(&0.0, 2, 1);
hist.fill_with_weighted(&0.0, 2, 2);
hist.fill_with_weighted(&0.0, 4, 3);

let weightedmean = hist.value(&0.0);
assert_eq!(weightedmean.unwrap().get(), 3.0);

Implementations

impl<T, W, O, C> WeightedMean<T, W, O, C> where
    T: Copy,
    W: Copy,
    O: From<T> + From<W> + From<C> + NumOps + Signed + Copy,
    C: Copy
[src]

pub fn new<I>(values: I) -> Self where
    I: IntoIterator<Item = (T, W)>,
    Self: FillWithWeighted<T, W> + Default
[src]

Factory method to create a Mean from a set of values.

Usually this will not be used as a Histogram will be responsible for creating and filling values.

pub fn get(&self) -> O[src]

Get the current value of the mean.

pub fn mean(&self) -> <O as Div>::Output[src]

Get the current value of the mean.

pub fn num_samples(&self) -> C[src]

Get the number of times the mean value has been filled.

pub fn variance_of_samples(&self) -> O[src]

Compute the variance of the samples.

pub fn standard_deviation_of_samples(&self) -> O where
    O: Float
[src]

The square root of the variance of the samples.

pub fn variance_of_mean(&self) -> O[src]

The square of the standard error of the mean.

pub fn standard_error_of_mean(&self) -> O where
    O: Float
[src]

Compute the standard error of the mean.

Trait Implementations

impl<T: Clone, W: Clone, O: Clone, C: Clone> Clone for WeightedMean<T, W, O, C>[src]

impl<T: Copy, W: Copy, O: Copy, C: Copy> Copy for WeightedMean<T, W, O, C>[src]

impl<T: Debug, W: Debug, O: Debug, C: Debug> Debug for WeightedMean<T, W, O, C>[src]

impl<T: Default, W: Default, O: Default, C: Default> Default for WeightedMean<T, W, O, C>[src]

impl<'de, T, W, O, C> Deserialize<'de> for WeightedMean<T, W, O, C> where
    T: Deserialize<'de>,
    W: Deserialize<'de>,
    C: Deserialize<'de>, 
[src]

impl<T: Eq, W: Eq, O: Eq, C: Eq> Eq for WeightedMean<T, W, O, C>[src]

impl<T, W, O, C> FillWithWeighted<T, W> for WeightedMean<T, W, O, C> where
    T: Copy + AddAssign + Mul<W, Output = T> + Mul<T, Output = T>,
    W: Copy + AddAssign + Mul<W, Output = W>,
    C: AddAssign + One
[src]

impl<T: Hash, W: Hash, O: Hash, C: Hash> Hash for WeightedMean<T, W, O, C>[src]

impl<T: Ord, W: Ord, O: Ord, C: Ord> Ord for WeightedMean<T, W, O, C>[src]

impl<T: PartialEq, W: PartialEq, O: PartialEq, C: PartialEq> PartialEq<WeightedMean<T, W, O, C>> for WeightedMean<T, W, O, C>[src]

impl<T: PartialOrd, W: PartialOrd, O: PartialOrd, C: PartialOrd> PartialOrd<WeightedMean<T, W, O, C>> for WeightedMean<T, W, O, C>[src]

impl<T, W, O, C> Serialize for WeightedMean<T, W, O, C> where
    T: Serialize,
    W: Serialize,
    C: Serialize
[src]

impl<T, W, O, C> StructuralEq for WeightedMean<T, W, O, C>[src]

impl<T, W, O, C> StructuralPartialEq for WeightedMean<T, W, O, C>[src]

Auto Trait Implementations

impl<T, W, O, C> RefUnwindSafe for WeightedMean<T, W, O, C> where
    C: RefUnwindSafe,
    O: RefUnwindSafe,
    T: RefUnwindSafe,
    W: RefUnwindSafe
[src]

impl<T, W, O, C> Send for WeightedMean<T, W, O, C> where
    C: Send,
    O: Send,
    T: Send,
    W: Send
[src]

impl<T, W, O, C> Sync for WeightedMean<T, W, O, C> where
    C: Sync,
    O: Sync,
    T: Sync,
    W: Sync
[src]

impl<T, W, O, C> Unpin for WeightedMean<T, W, O, C> where
    C: Unpin,
    O: Unpin,
    T: Unpin,
    W: Unpin
[src]

impl<T, W, O, C> UnwindSafe for WeightedMean<T, W, O, C> where
    C: UnwindSafe,
    O: UnwindSafe,
    T: UnwindSafe,
    W: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.