pub trait Iterstats<A>: Iterator {
// Provided methods
fn mean(self) -> <A as Mean>::Output
where Self: Sized + Iterator<Item = A> + Clone,
A: Mean { ... }
fn variance(self) -> <A as Variance>::Output
where Self: Sized + Iterator<Item = A>,
A: Variance { ... }
fn stddev(self) -> <A as StdDev>::Output
where Self: Sized + Iterator<Item = A>,
A: StdDev { ... }
fn zscore(self) -> ZScoreIter<<A as ZScore>::Output> ⓘ
where Self: Sized + Iterator<Item = A> + Clone,
A: ZScore { ... }
fn normalize(
self,
min: <A as Normalize>::Output,
max: <A as Normalize>::Output,
) -> NormalizeIter<<A as Normalize>::Output> ⓘ
where Self: Sized + Iterator<Item = A> + Clone,
A: Normalize { ... }
fn sum_of_squares(self) -> <A as SumOfSquares>::Output
where Self: Sized + Iterator<Item = A>,
A: SumOfSquares { ... }
fn median(self) -> <A as Median>::Output
where Self: Sized + Iterator<Item = A>,
A: Median { ... }
fn range(self) -> Option<(<A as Range>::Output, <A as Range>::Output)>
where Self: Sized + Iterator<Item = A>,
A: Range { ... }
fn fill_nan(
self,
repl: <A as FillNan>::Output,
) -> FillNanIter<impl Iterator<Item = <A as FillNan>::Output>, <A as FillNan>::Output> ⓘ
where Self: Sized + Iterator<Item = A>,
A: FillNan { ... }
fn argsort(self) -> ArgSortIter<<A as ArgSort>::Output> ⓘ
where Self: Sized + Iterator<Item = A>,
A: ArgSort { ... }
fn rank(self) -> RankIter ⓘ
where Self: Sized + Iterator<Item = A>,
A: Rank { ... }
}Expand description
This trait allows you to call all the iterstats calculations as iterator methods.
§Example
use iterstats::Iterstats;
let data = [1f32, 2., 3., 4.];
let mean = data.iter().mean();
assert_eq!(mean, 2.5);
let variance = data.iter().variance();
assert_eq!(variance, 1.25);
let stddev = data.iter().stddev();
assert_eq!(stddev, 1.25f32.sqrt());
let zscores = data.iter().zscore().collect::<Vec<_>>();
assert_eq!(zscores, vec![-1.3416407, -0.4472136, 0.4472136, 1.3416407]);Provided Methods§
Sourcefn stddev(self) -> <A as StdDev>::Output
fn stddev(self) -> <A as StdDev>::Output
Calculate the population standard deviation of the collection.
Sourcefn zscore(self) -> ZScoreIter<<A as ZScore>::Output> ⓘ
fn zscore(self) -> ZScoreIter<<A as ZScore>::Output> ⓘ
Calculate the Z-score of each item of the collection.
Sourcefn normalize(
self,
min: <A as Normalize>::Output,
max: <A as Normalize>::Output,
) -> NormalizeIter<<A as Normalize>::Output> ⓘ
fn normalize( self, min: <A as Normalize>::Output, max: <A as Normalize>::Output, ) -> NormalizeIter<<A as Normalize>::Output> ⓘ
Normalize each item of the collection to a specified range.
use iterstats::Iterstats;
let data = [-1.0f64, -2., 3., 8.];
let norm = data.iter().normalize(0., 100.).collect::<Vec<_>>();
assert_eq!(vec![10., 0., 50., 100.], norm);Sourcefn sum_of_squares(self) -> <A as SumOfSquares>::Output
fn sum_of_squares(self) -> <A as SumOfSquares>::Output
Calculate the total sum of squares of the collection.
Sourcefn median(self) -> <A as Median>::Output
fn median(self) -> <A as Median>::Output
Calculate the median of the collection.
For integer types this may be inexact if there are an even number of elements and the true median is a non-integer number.
Sourcefn range(self) -> Option<(<A as Range>::Output, <A as Range>::Output)>
fn range(self) -> Option<(<A as Range>::Output, <A as Range>::Output)>
Calculate the range of the collection.
This gets the minimum & maximum in 1 pass. Returned is a tuple of Some((min, max)),
unless the iterator is empty, in which case None is returned.
Sourcefn fill_nan(
self,
repl: <A as FillNan>::Output,
) -> FillNanIter<impl Iterator<Item = <A as FillNan>::Output>, <A as FillNan>::Output> ⓘ
fn fill_nan( self, repl: <A as FillNan>::Output, ) -> FillNanIter<impl Iterator<Item = <A as FillNan>::Output>, <A as FillNan>::Output> ⓘ
Replace NANs with another value.