pub trait Stats {
Show 27 methods
fn vmag(self) -> f64;
fn vmagsq(self) -> f64;
fn vreciprocal(self) -> Result<Vec<f64, Global>, Error>;
fn vinverse(self) -> Result<Vec<f64, Global>, Error>;
fn negv(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
;
fn vunit(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
;
fn pdf(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
;
fn entropy(self) -> f64;
fn autocorr(self) -> f64;
fn lintrans(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
;
fn symmatrix(self) -> Vec<Vec<f64, Global>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
;
fn amean(self) -> Result<f64, Error> { ... }
fn ameanstd(self) -> Result<MStats, Error> { ... }
fn awmean(self) -> Result<f64, Error> { ... }
fn awmeanstd(self) -> Result<MStats, Error> { ... }
fn hmean(self) -> Result<f64, Error> { ... }
fn hmeanstd(self) -> Result<MStats, Error> { ... }
fn hwmean(self) -> Result<f64, Error> { ... }
fn hwmeanstd(self) -> Result<MStats, Error> { ... }
fn gmean(self) -> Result<f64, Error> { ... }
fn gmeanstd(self) -> Result<MStats, Error> { ... }
fn gwmean(self) -> Result<f64, Error> { ... }
fn gwmeanstd(self) -> Result<MStats, Error> { ... }
fn median(self) -> Result<Med, Error> { ... }
fn newmedian(self) -> Result<f64, Error> { ... }
fn mad(self) -> Result<f64, Error> { ... }
fn zeromedian(self) -> Result<Vec<f64, Global>, Error> { ... }
}
Expand description
Statistical measures of a single variable (one generic vector of data) and
vector algebra applicable to a single (generic) vector.
Thus these methods take no arguments.
There is just one limitation: data of end type i64
has to be explicitly converted to f64
.
That is to raise awareness that, in this particular case, some precision may be lost.
Function statsg::i64tof64(&s)
will convert the whole slice.
Required methods
fn negv(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Unit vector
Probability density function of a sorted slice
(Auto)correlation coefficient of pairs of successive values of (time series) variable.
Linear transform to interval [0,1]
Provided methods
Weighted geometric mean and standard deviation ratio
MAD median absolute deviation: data spread estimator that is more stable than variance
Implementations on Foreign Types
sourceimpl<'_, T> Stats for &'_ [T] where
T: Copy + PartialOrd<T> + Display,
f64: From<T>,
impl<'_, T> Stats for &'_ [T] where
T: Copy + PartialOrd<T> + Display,
f64: From<T>,
sourcefn vunit(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn vunit(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Unit vector
sourcefn amean(self) -> Result<f64, Error>
fn amean(self) -> Result<f64, Error>
Arithmetic mean
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
assert_eq!(v1.as_slice().amean().unwrap(),7.5_f64);
sourcefn ameanstd(self) -> Result<MStats, Error>
fn ameanstd(self) -> Result<MStats, Error>
Arithmetic mean and (population) standard deviation
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
let res = v1.as_slice().ameanstd().unwrap();
assert_eq!(res.mean,7.5_f64);
assert_eq!(res.std,4.031128874149275_f64);
sourcefn awmean(self) -> Result<f64, Error>
fn awmean(self) -> Result<f64, Error>
Linearly weighted arithmetic mean of an f64 slice.
Linearly ascending weights from 1 to n.
Time dependent data should be in the order of time increasing.
Then the most recent gets the most weight.
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
assert_eq!(v1.as_slice().awmean().unwrap(),9.666666666666666_f64);
sourcefn awmeanstd(self) -> Result<MStats, Error>
fn awmeanstd(self) -> Result<MStats, Error>
Linearly weighted arithmetic mean and standard deviation of an f64 slice.
Linearly ascending weights from 1 to n.
Time dependent data should be in the order of time increasing.
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
let res = v1.as_slice().awmeanstd().unwrap();
assert_eq!(res.mean,9.666666666666666_f64);
assert_eq!(res.std,3.399346342395192_f64);
sourcefn hmean(self) -> Result<f64, Error>
fn hmean(self) -> Result<f64, Error>
Harmonic mean of an f64 slice.
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
assert_eq!(v1.as_slice().hmean().unwrap(),4.305622526633627_f64);
sourcefn hmeanstd(self) -> Result<MStats, Error>
fn hmeanstd(self) -> Result<MStats, Error>
Harmonic mean and standard deviation std is based on reciprocal moments
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
let res = v1.as_slice().hmeanstd().unwrap();
assert_eq!(res.mean,4.305622526633627_f64);
assert_eq!(res.std,1.1996764516690959_f64);
sourcefn hwmean(self) -> Result<f64, Error>
fn hwmean(self) -> Result<f64, Error>
Linearly weighted harmonic mean of an f64 slice.
Linearly ascending weights from 1 to n.
Time dependent data should be ordered by increasing time.
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
assert_eq!(v1.as_slice().hwmean().unwrap(),7.5_f64);
sourcefn hwmeanstd(self) -> Result<MStats, Error>
fn hwmeanstd(self) -> Result<MStats, Error>
Weighted harmonic mean and standard deviation std is based on reciprocal moments
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
let res = v1.as_slice().hmeanstd().unwrap();
assert_eq!(res.mean,4.305622526633627_f64);
assert_eq!(res.std,1.1996764516690959_f64);
sourcefn gmean(self) -> Result<f64, Error>
fn gmean(self) -> Result<f64, Error>
Geometric mean of an i64 slice.
The geometric mean is just an exponential of an arithmetic mean
of log data (natural logarithms of the data items).
The geometric mean is less sensitive to outliers near maximal value.
Zero valued data is not allowed!
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
assert_eq!(v1.as_slice().gmean().unwrap(),6.045855171418503_f64);
sourcefn gmeanstd(self) -> Result<MStats, Error>
fn gmeanstd(self) -> Result<MStats, Error>
Geometric mean and std ratio of an f64 slice.
Zero valued data is not allowed.
Std of ln data becomes a ratio after conversion back.
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
let res = v1.as_slice().gmeanstd().unwrap();
assert_eq!(res.mean,6.045855171418503_f64);
assert_eq!(res.std,2.1084348239406303_f64);
sourcefn gwmean(self) -> Result<f64, Error>
fn gwmean(self) -> Result<f64, Error>
Linearly weighted geometric mean of an i64 slice.
Ascending weights from 1 down to n.
Time dependent data should be in time increasing order.
The geometric mean is an exponential of an arithmetic mean
of log data (natural logarithms of the data items).
The geometric mean is less sensitive to outliers near maximal value.
Zero valued data is not allowed!
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
assert_eq!(v1.as_slice().gwmean().unwrap(),8.8185222496341_f64);
sourcefn gwmeanstd(self) -> Result<MStats, Error>
fn gwmeanstd(self) -> Result<MStats, Error>
Linearly weighted version of gmeanstd.
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
let res = v1.as_slice().gwmeanstd().unwrap();
assert_eq!(res.mean,8.8185222496341_f64);
assert_eq!(res.std,1.626825493266009_f64);
sourcefn median(self) -> Result<Med, Error>
fn median(self) -> Result<Med, Error>
Median of a &[T] slice by sorting
Example
use rstats::{Stats};
let v1 = vec![1_u8,2,3,4,5,6,7,8,9,10,11,12,13,14];
let res = &v1.median().unwrap();
assert_eq!(res.median,7.5_f64);
assert_eq!(res.lquartile,4.25_f64);
assert_eq!(res.uquartile,10.75_f64);
sourcefn mad(self) -> Result<f64, Error>
fn mad(self) -> Result<f64, Error>
MAD median absolute deviation: data spread estimator that is more stable than variance and more precise than quartiles
sourcefn zeromedian(self) -> Result<Vec<f64, Global>, Error>
fn zeromedian(self) -> Result<Vec<f64, Global>, Error>
Zero median data produced by subtracting the median. Analogous to zero mean data when subtracting the mean.
sourcefn pdf(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn pdf(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Probability density function of a sorted slice with repeats. Repeats are counted and removed
sourcefn autocorr(self) -> f64
fn autocorr(self) -> f64
(Auto)correlation coefficient of pairs of successive values of (time series) f64 variable.
Example
use rstats::Stats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
assert_eq!(v1.autocorr(),0.9984603532054123_f64);
sourcefn lintrans(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn lintrans(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Linear transform to interval [0,1]
sourcefn symmatrix(self) -> Vec<Vec<f64, Global>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn symmatrix(self) -> Vec<Vec<f64, Global>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Reconstructs the full symmetric square matrix from its lower diagonal compact form, as produced by covar, covone, wcovar
fn negv(self) -> Vec<f64, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,