pub trait Stats {
Show 26 methods
// Required methods
fn vmag(self) -> f64;
fn vmagsq(self) -> f64;
fn vreciprocal(self) -> Result<Vec<f64>, RE>;
fn vinverse(self) -> Result<Vec<f64>, RE>;
fn negv(self) -> Result<Vec<f64>, RE>;
fn vunit(self) -> Result<Vec<f64>, RE>;
fn hmad(self) -> Result<f64, RE>;
fn amean(self) -> Result<f64, RE>;
fn medmad(self) -> Result<Params, RE>;
fn ameanstd(self) -> Result<Params, RE>;
fn awmean(self) -> Result<f64, RE>;
fn awmeanstd(self) -> Result<Params, RE>;
fn hmean(self) -> Result<f64, RE>;
fn hmeanstd(self) -> Result<Params, RE>;
fn hwmean(self) -> Result<f64, RE>;
fn hwmeanstd(self) -> Result<Params, RE>;
fn gmean(self) -> Result<f64, RE>;
fn gmeanstd(self) -> Result<Params, RE>;
fn gwmean(self) -> Result<f64, RE>;
fn gwmeanstd(self) -> Result<Params, RE>;
fn pdf(self) -> Vec<f64>;
fn entropy(self) -> f64;
fn autocorr(self) -> Result<f64, RE>;
fn lintrans(self) -> Result<Vec<f64>, RE>;
fn dfdt(self, centre: f64) -> Result<f64, RE>;
fn house_reflector(self) -> Vec<f64>;
}
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.
Required Methods§
sourcefn autocorr(self) -> Result<f64, RE>
fn autocorr(self) -> Result<f64, RE>
(Auto)correlation coefficient of pairs of successive values of (time series) variable.
sourcefn dfdt(self, centre: f64) -> Result<f64, RE>
fn dfdt(self, centre: f64) -> Result<f64, RE>
Linearly weighted approximate time series derivative at the last (present time) point.
sourcefn house_reflector(self) -> Vec<f64>
fn house_reflector(self) -> Vec<f64>
Householder reflection
Implementations on Foreign Types§
source§impl<T> Stats for &[T]
impl<T> Stats for &[T]
source§fn amean(self) -> Result<f64, RE>
fn amean(self) -> Result<f64, RE>
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.amean().unwrap(),7.5_f64);
source§fn ameanstd(self) -> Result<Params, RE>
fn ameanstd(self) -> Result<Params, RE>
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.ameanstd().unwrap();
assert_eq!(res.centre,7.5_f64);
assert_eq!(res.spread,4.031128874149275_f64);
source§fn awmean(self) -> Result<f64, RE>
fn awmean(self) -> Result<f64, RE>
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.awmean().unwrap(),9.666666666666666_f64);
source§fn awmeanstd(self) -> Result<Params, RE>
fn awmeanstd(self) -> Result<Params, RE>
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.awmeanstd().unwrap();
assert_eq!(res.centre,9.666666666666666_f64);
assert_eq!(res.spread,3.399346342395192_f64);
source§fn hmean(self) -> Result<f64, RE>
fn hmean(self) -> Result<f64, RE>
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.hmean().unwrap(),4.305622526633627_f64);
source§fn hmeanstd(self) -> Result<Params, RE>
fn hmeanstd(self) -> Result<Params, RE>
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.hmeanstd().unwrap();
assert_eq!(res.centre,4.305622526633627_f64);
assert_eq!(res.spread,1.1996764516690959_f64);
source§fn hwmean(self) -> Result<f64, RE>
fn hwmean(self) -> Result<f64, RE>
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.hwmean().unwrap(),7.5_f64);
source§fn hwmeanstd(self) -> Result<Params, RE>
fn hwmeanstd(self) -> Result<Params, RE>
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.hmeanstd().unwrap();
assert_eq!(res.centre,4.305622526633627_f64);
assert_eq!(res.spread,1.1996764516690959_f64);
source§fn gmean(self) -> Result<f64, RE>
fn gmean(self) -> Result<f64, RE>
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.gmean().unwrap(),6.045855171418503_f64);
source§fn gmeanstd(self) -> Result<Params, RE>
fn gmeanstd(self) -> Result<Params, RE>
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.gmeanstd().unwrap();
assert_eq!(res.centre,6.045855171418503_f64);
assert_eq!(res.spread,2.1084348239406303_f64);
source§fn gwmean(self) -> Result<f64, RE>
fn gwmean(self) -> Result<f64, RE>
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.gwmean().unwrap(),8.8185222496341_f64);
source§fn gwmeanstd(self) -> Result<Params, RE>
fn gwmeanstd(self) -> Result<Params, RE>
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.gwmeanstd().unwrap();
assert_eq!(res.centre,8.8185222496341_f64);
assert_eq!(res.spread,1.626825493266009_f64);
source§fn pdf(self) -> Vec<f64>
fn pdf(self) -> Vec<f64>
Probability density function of a sorted slice with repeats. Repeats are counted and removed
source§fn autocorr(self) -> Result<f64, RE>
fn autocorr(self) -> Result<f64, RE>
(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().unwrap(),0.9984603532054123_f64);
source§fn dfdt(self, centre: f64) -> Result<f64, RE>
fn dfdt(self, centre: f64) -> Result<f64, RE>
Linearly weighted approximate time series derivative at the last point (present time). Weighted sum (backwards half filter), minus the median. Rising values return positive result and vice versa.
source§fn house_reflector(self) -> Vec<f64>
fn house_reflector(self) -> Vec<f64>
Householder reflector