Struct average::Variance[][src]

pub struct Variance { /* fields omitted */ }

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]

Estimate the standard error of the mean of the population.

Trait Implementations

impl Clone for Variance[src]

impl Debug for Variance[src]

impl Default for Variance[src]

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

impl Estimate for Variance[src]

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

impl FromIterator<f64> for Variance[src]

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

impl FromParallelIterator<f64> for Variance[src]

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]

Auto Trait Implementations

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<S, T> Cast<T> for S where
    T: Conv<S>, 
[src]

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

impl<T> Conv<T> for T[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> Pointable for T

type Init = T

The type for initializers.

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.