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(Into::into).collect();
println!("The mean is {} ± {}.", a.mean(), a.error());

Methods

impl Variance
[src]

[src]

Create a new variance estimator.

[src]

Determine whether the sample is empty.

[src]

Estimate the mean of the population.

Returns 0 for an empty sample.

[src]

Return the sample size.

[src]

Calculate the sample variance.

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

[src]

Calculate the population variance of the sample.

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

[src]

Estimate the standard error of the mean of the population.

Trait Implementations

impl Debug for Variance
[src]

[src]

Formats the value using the given formatter.

impl Clone for Variance
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for Variance
[src]

[src]

Returns the "default value" for a type. Read more

impl Estimate for Variance
[src]

[src]

Add an observation sampled from the population.

[src]

Estimate the statistic of the population.

impl Merge for Variance
[src]

[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().map(|x| *x).collect();
let mut avg_left: Variance = left.iter().map(|x| *x).collect();
let avg_right: Variance = right.iter().map(|x| *x).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 FromIterator<f64> for Variance
[src]

[src]

Creates a value from an iterator. Read more