pub struct Mean { /* private fields */ }
Expand description
Estimate the arithmetic mean of a sequence of numbers (“population”).
§Example
use average::Mean;
let a: Mean = (1..6).map(f64::from).collect();
println!("The mean is {}.", a.mean());
Implementations§
Trait Implementations§
source§impl<'de> Deserialize<'de> for Mean
impl<'de> Deserialize<'de> for Mean
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<'a> Extend<&'a f64> for Mean
impl<'a> Extend<&'a f64> for Mean
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = &'a f64>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = &'a f64>,
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl Extend<f64> for Mean
impl Extend<f64> for Mean
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = f64>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = f64>,
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl<'a> FromIterator<&'a f64> for Mean
impl<'a> FromIterator<&'a f64> for Mean
source§impl FromIterator<f64> for Mean
impl FromIterator<f64> for Mean
source§impl<'a> FromParallelIterator<&'a f64> for Mean
Available on crate feature rayon
only.
impl<'a> FromParallelIterator<&'a f64> for Mean
Available on crate feature
rayon
only.source§fn from_par_iter<I>(par_iter: I) -> Mean
fn from_par_iter<I>(par_iter: I) -> Mean
Creates an instance of the collection from the parallel iterator
par_iter
. Read moresource§impl FromParallelIterator<f64> for Mean
Available on crate feature rayon
only.
impl FromParallelIterator<f64> for Mean
Available on crate feature
rayon
only.source§fn from_par_iter<I>(par_iter: I) -> Mean
fn from_par_iter<I>(par_iter: I) -> Mean
Creates an instance of the collection from the parallel iterator
par_iter
. Read moresource§impl Merge for Mean
impl Merge for Mean
source§fn merge(&mut self, other: &Mean)
fn merge(&mut self, other: &Mean)
Merge another sample into this one.
§Example
use average::{Mean, Merge};
let sequence: &[f64] = &[1., 2., 3., 4., 5., 6., 7., 8., 9.];
let (left, right) = sequence.split_at(3);
let avg_total: Mean = sequence.iter().collect();
let mut avg_left: Mean = left.iter().collect();
let avg_right: Mean = right.iter().collect();
avg_left.merge(&avg_right);
assert_eq!(avg_total.mean(), avg_left.mean());
Auto Trait Implementations§
impl Freeze for Mean
impl RefUnwindSafe for Mean
impl Send for Mean
impl Sync for Mean
impl Unpin for Mean
impl UnwindSafe for Mean
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more