Struct average::Max
[−]
[src]
pub struct Max { /* fields omitted */ }
Estimate the maximum of a sequence of numbers ("population").
Example
use average::Max; let a: Max = (1..6).map(Into::into).collect(); assert_eq!(a.max(), 5.);
Methods
impl Max
[src]
fn from_value(x: f64) -> Max
[src]
Create a new maxium estimator from a given value.
fn new() -> Max
[src]
Create a new maximum estimator.
fn max(&self) -> f64
[src]
Estimate the maxium of the population.
Trait Implementations
impl Debug for Max
[src]
impl Clone for Max
[src]
fn clone(&self) -> Max
[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 Default for Max
[src]
impl FromIterator<f64> for Max
[src]
fn from_iter<T>(iter: T) -> Max where
T: IntoIterator<Item = f64>,
[src]
T: IntoIterator<Item = f64>,
Creates a value from an iterator. Read more
impl Estimate for Max
[src]
fn add(&mut self, x: f64)
[src]
Add an observation sampled from the population.
fn estimate(&self) -> f64
[src]
Estimate the statistic of the population.
impl Merge for Max
[src]
fn merge(&mut self, other: &Max)
[src]
Merge another sample into this one.
Example
use average::{Max, Merge}; let sequence: &[f64] = &[1., 2., 3., 4., 5., 6., 7., 8., 9.]; let (left, right) = sequence.split_at(3); let max_total: Max = sequence.iter().map(|x| *x).collect(); let mut max_left: Max = left.iter().map(|x| *x).collect(); let max_right: Max = right.iter().map(|x| *x).collect(); max_left.merge(&max_right); assert_eq!(max_total.max(), max_left.max());