[][src]Trait rstats::RStats

pub trait RStats {
    fn amean(&self) -> Result<f64>;
fn ameanstd(&self) -> Result<MStats>;
fn awmean(&self) -> Result<f64>;
fn awmeanstd(&self) -> Result<MStats>;
fn hmean(&self) -> Result<f64>;
fn hwmean(&self) -> Result<f64>;
fn gmean(&self) -> Result<f64>;
fn gwmean(&self) -> Result<f64>;
fn gmeanstd(&self) -> Result<MStats>;
fn gwmeanstd(&self) -> Result<MStats>;
fn median(&self) -> Result<Med>;
fn correlation(&self, other: &[i64]) -> Result<f64>;
fn fcorrelation(&self, other: &[f64]) -> Result<f64>;
fn autocorr(&self) -> Result<f64>; }

Required methods

fn amean(&self) -> Result<f64>

fn ameanstd(&self) -> Result<MStats>

fn awmean(&self) -> Result<f64>

fn awmeanstd(&self) -> Result<MStats>

fn hmean(&self) -> Result<f64>

fn hwmean(&self) -> Result<f64>

fn gmean(&self) -> Result<f64>

fn gwmean(&self) -> Result<f64>

fn gmeanstd(&self) -> Result<MStats>

fn gwmeanstd(&self) -> Result<MStats>

fn median(&self) -> Result<Med>

fn correlation(&self, other: &[i64]) -> Result<f64>

fn fcorrelation(&self, other: &[f64]) -> Result<f64>

fn autocorr(&self) -> Result<f64>

Loading content...

Implementations on Foreign Types

impl RStats for Vec<i64>[src]

fn amean(&self) -> Result<f64>[src]

Arithmetic mean of an i64 slice

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
assert_eq!(v1.amean().unwrap(),7.5_f64);

fn ameanstd(&self) -> Result<MStats>[src]

Arithmetic mean and standard deviation of an i64 slice

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
let res = v1.ameanstd().unwrap();
assert_eq!(res.mean,7.5_f64);
assert_eq!(res.std,4.031128874149275_f64);

fn awmean(&self) -> Result<f64>[src]

Linearly weighted arithmetic mean of an i64 slice.
Linearly descending weights from n down to one.
Time dependent data should be in the stack order - the last being the oldest.

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
assert_eq!(v1.awmean().unwrap(),5.333333333333333_f64);

fn awmeanstd(&self) -> Result<MStats>[src]

Liearly weighted arithmetic mean and standard deviation of an i64 slice.
Linearly descending weights from n down to one.
Time dependent data should be in the stack order - the last being the oldest.

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
let res = v1.awmeanstd().unwrap();
assert_eq!(res.mean,5.333333333333333_f64);
assert_eq!(res.std,3.39934634239519_f64);

fn hmean(&self) -> Result<f64>[src]

Harmonic mean of an i64 slice.

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
assert_eq!(v1.hmean().unwrap(),4.305622526633627_f64);

fn hwmean(&self) -> Result<f64>[src]

Linearly weighted harmonic mean of an i64 slice.
Linearly descending weights from n down to one.
Time dependent data should be in the stack order - the last being the oldest.

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
assert_eq!(v1.hwmean().unwrap(),3.019546395306663_f64);

fn gmean(&self) -> Result<f64>[src]

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::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
assert_eq!(v1.gmean().unwrap(),6.045855171418503_f64);

fn gwmean(&self) -> Result<f64>[src]

Linearly weighted geometric mean of an i64 slice.
Descending weights from n down to one.
Time dependent data should be in the stack order - the last being the oldest.
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 data is not allowed - would at best only produce zero result.

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
assert_eq!(v1.gwmean().unwrap(),4.144953510241978_f64);

fn gmeanstd(&self) -> Result<MStats>[src]

Geometric mean and std ratio of an i64 slice.
Zero valued data is not allowed.
Std of ln data becomes a ratio after conversion back.

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
let res = v1.gmeanstd().unwrap();
assert_eq!(res.mean,6.045855171418503_f64);
assert_eq!(res.std,2.1084348239406303_f64);

fn gwmeanstd(&self) -> Result<MStats>[src]

Linearly weighted version of gmeanstd.

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
let res = v1.gwmeanstd().unwrap();
assert_eq!(res.mean,4.144953510241978_f64);
assert_eq!(res.std,2.1572089236412597_f64);

fn median(&self) -> Result<Med>[src]

Fast median (avoids sorting).
The data values must be within a moderate range not exceeding u16size (65535).

Example

use rstats::RStats;
let v1 = vec![1_i64,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_f64);
assert_eq!(res.uquartile,11_f64);

fn correlation(&self, v2: &[i64]) -> Result<f64>[src]

Correlation coefficient of a sample of two integer variables.

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
let v2 = vec![14_i64,13,12,11,10,9,8,7,6,5,4,3,2,1];
assert_eq!(v1.correlation(&v2).unwrap(),-1_f64);

fn fcorrelation(&self, v2: &[f64]) -> Result<f64>[src]

Correlation coefficient of samples of i64 and f64 variables.

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
let v2 = vec![14_f64,13.,12.,11.,10.,9.,8.,7.,6.,5.,4.,3.,2.,1.];
assert_eq!(v1.fcorrelation(&v2).unwrap(),-1_f64);

fn autocorr(&self) -> Result<f64>[src]

(Auto)correlation coefficient of pairs of successive values of (time series) integer variable.

Example

use rstats::RStats;
let v1 = vec![1_i64,2,3,4,5,6,7,8,9,10,11,12,13,14];
assert_eq!(v1.autocorr().unwrap(),0.9984603532054123_f64);

impl RStats for Vec<f64>[src]

fn amean(&self) -> Result<f64>[src]

Arithmetic mean of an f64 slice

Example

use rstats::RStats;
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);

fn ameanstd(&self) -> Result<MStats>[src]

Arithmetic mean and standard deviation of an f64 slice

Example

use rstats::RStats;
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.mean,7.5_f64);
assert_eq!(res.std,4.031128874149275_f64);

fn awmean(&self) -> Result<f64>[src]

Linearly weighted arithmetic mean of an f64 slice.
Linearly descending weights from n down to one.
Time dependent data should be in the stack order - the last being the oldest.

Example

use rstats::RStats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
assert_eq!(v1.awmean().unwrap(),5.333333333333333_f64);

fn awmeanstd(&self) -> Result<MStats>[src]

Liearly weighted arithmetic mean and standard deviation of an f64 slice.
Linearly descending weights from n down to one.
Time dependent data should be in the stack order - the last being the oldest.

Example

use rstats::RStats;
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.mean,5.333333333333333_f64);
assert_eq!(res.std,3.39934634239519_f64);

fn hmean(&self) -> Result<f64>[src]

Harmonic mean of an f64 slice.

Example

use rstats::RStats;
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);

fn hwmean(&self) -> Result<f64>[src]

Linearly weighted harmonic mean of an f64 slice.
Linearly descending weights from n down to one.
Time dependent data should be in the stack order - the last being the oldest.

Example

use rstats::RStats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
assert_eq!(v1.hwmean().unwrap(),3.019546395306663_f64);

fn gmean(&self) -> Result<f64>[src]

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::RStats;
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);

fn gwmean(&self) -> Result<f64>[src]

Linearly weighted geometric mean of an i64 slice.
Descending weights from n down to one.
Time dependent data should be in the stack order - the last being the oldest.
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 data is not allowed - would at best only produce zero result.

Example

use rstats::RStats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
assert_eq!(v1.gwmean().unwrap(),4.144953510241978_f64);

fn gmeanstd(&self) -> Result<MStats>[src]

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::RStats;
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.mean,6.045855171418503_f64);
assert_eq!(res.std,2.1084348239406303_f64);

fn gwmeanstd(&self) -> Result<MStats>[src]

Linearly weighted version of gmeanstd.

Example

use rstats::RStats;
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.mean,4.144953510241978_f64);
assert_eq!(res.std,2.1572089236412597_f64);

fn median(&self) -> Result<Med>[src]

Median of an f64 slice

Example

use rstats::RStats;
let v1 = vec![1_f64,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_f64);
assert_eq!(res.uquartile,11_f64);

fn correlation(&self, v2: &[i64]) -> Result<f64>[src]

Correlation coefficient of a sample of f64 and i64 variables.

Example

use rstats::RStats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
let v2 = vec![14_i64,13,12,11,10,9,8,7,6,5,4,3,2,1];
assert_eq!(v1.correlation(&v2).unwrap(),-1_f64);

fn fcorrelation(&self, v2: &[f64]) -> Result<f64>[src]

Correlation coefficient of a sample of two f64 variables.

Example

use rstats::RStats;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
let v2 = vec![14_f64,13.,12.,11.,10.,9.,8.,7.,6.,5.,4.,3.,2.,1.];
assert_eq!(v1.fcorrelation(&v2).unwrap(),-1_f64);

fn autocorr(&self) -> Result<f64>[src]

(Auto)correlation coefficient of pairs of successive values of (time series) f64 variable.

Example

use rstats::RStats;
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);
Loading content...

Implementors

Loading content...