Struct average::Variance[][src]

pub struct Variance { /* fields omitted */ }
Expand description

Estimate the arithmetic mean and the variance of a sequence of numbers (“population”).

This can be used to estimate the standard error of the mean.

Example

use average::Variance;

let a: Variance = (1..6).map(f64::from).collect();
println!("The mean is {} ± {}.", a.mean(), a.error());

Implementations

impl Variance[src]

pub fn new() -> Variance[src]

Create a new variance estimator.

pub fn is_empty(&self) -> bool[src]

Determine whether the sample is empty.

pub fn mean(&self) -> f64[src]

Estimate the mean of the population.

Returns 0 for an empty sample.

pub fn len(&self) -> u64[src]

Return the sample size.

pub fn sample_variance(&self) -> f64[src]

Calculate the sample variance.

This is an unbiased estimator of the variance of the population.

pub fn population_variance(&self) -> f64[src]

Calculate the population variance of the sample.

This is a biased estimator of the variance of the population.

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

Estimate the variance of the mean of the population.

pub fn error(&self) -> f64[src]

This is supported on crate features std or libm only.

Estimate the standard error of the mean of the population.

Trait Implementations

impl Clone for Variance[src]

fn clone(&self) -> Variance[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Variance[src]

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

Formats the value using the given formatter. Read more

impl Default for Variance[src]

fn default() -> Variance[src]

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

impl<'de> Deserialize<'de> for Variance[src]

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl Estimate for Variance[src]

fn add(&mut self, sample: f64)[src]

Add an observation sampled from the population.

fn estimate(&self) -> f64[src]

Estimate the statistic of the population.

impl<'a> FromIterator<&'a f64> for Variance[src]

fn from_iter<T>(iter: T) -> Variance where
    T: IntoIterator<Item = &'a f64>, 
[src]

Creates a value from an iterator. Read more

impl FromIterator<f64> for Variance[src]

fn from_iter<T>(iter: T) -> Variance where
    T: IntoIterator<Item = f64>, 
[src]

Creates a value from an iterator. Read more

impl<'a> FromParallelIterator<&'a f64> for Variance[src]

This is supported on crate feature rayon only.

fn from_par_iter<I>(par_iter: I) -> Variance where
    I: IntoParallelIterator<Item = &'a f64>,
    Self: Merge
[src]

Creates an instance of the collection from the parallel iterator par_iter. Read more

impl FromParallelIterator<f64> for Variance[src]

This is supported on crate feature rayon only.

fn from_par_iter<I>(par_iter: I) -> Variance where
    I: IntoParallelIterator<Item = f64>,
    Self: Merge
[src]

Creates an instance of the collection from the parallel iterator par_iter. Read more

impl Merge for Variance[src]

fn merge(&mut self, other: &Variance)[src]

Merge another sample into this one.

Example

use average::{Variance, Merge};

let sequence: &[f64] = &[1., 2., 3., 4., 5., 6., 7., 8., 9.];
let (left, right) = sequence.split_at(3);
let avg_total: Variance = sequence.iter().collect();
let mut avg_left: Variance = left.iter().collect();
let avg_right: Variance = right.iter().collect();
avg_left.merge(&avg_right);
assert_eq!(avg_total.mean(), avg_left.mean());
assert_eq!(avg_total.sample_variance(), avg_left.sample_variance());

impl Serialize for Variance[src]

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<S, T> Cast<T> for S where
    T: Conv<S>, 
[src]

pub fn cast(self) -> T[src]

Cast from Self to T

pub fn try_cast(self) -> Result<T, Error>[src]

Try converting from Self to T

impl<S, T> CastFloat<T> for S where
    T: ConvFloat<S>, 
[src]

pub fn cast_trunc(self) -> T[src]

Cast to integer, truncating Read more

pub fn cast_nearest(self) -> T[src]

Cast to the nearest integer Read more

pub fn cast_floor(self) -> T[src]

Cast the floor to an integer Read more

pub fn cast_ceil(self) -> T[src]

Cast the ceiling to an integer Read more

pub fn try_cast_trunc(self) -> Result<T, Error>[src]

Try converting to integer with truncation Read more

pub fn try_cast_nearest(self) -> Result<T, Error>[src]

Try converting to the nearest integer Read more

pub fn try_cast_floor(self) -> Result<T, Error>[src]

Try converting the floor to an integer Read more

pub fn try_cast_ceil(self) -> Result<T, Error>[src]

Try convert the ceiling to an integer Read more

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

pub fn conv(v: T) -> T[src]

Convert from T to Self

pub fn try_conv(v: T) -> Result<T, Error>[src]

Try converting from T to Self

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointable for T

pub const ALIGN: usize

The alignment of pointer.

type Init = T

The type for initializers.

pub unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more

pub unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more

pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more

pub unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

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.

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

Performs the conversion.

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.

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

Performs the conversion.

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