[][src]Trait rstats::Vectors

pub trait Vectors {
    fn dotp(self, v: &[f64]) -> f64;
fn vsub(self, v: &[f64]) -> Vec<f64>;
fn vadd(self, v: &[f64]) -> Vec<f64>;
fn vmag(self) -> f64;
fn vdist(self, v: &[f64]) -> f64;
fn smult(self, s: f64) -> Vec<f64>;
fn sadd(self, s: f64) -> Vec<f64>;
fn vunit(self) -> Vec<f64>;
fn correlation(self, v: &[f64]) -> Result<f64>;
fn kendalcorr(self, v: &[f64]) -> Result<f64>;
fn spearmancorr(self, v: &[f64]) -> Result<f64>;
fn autocorr(self) -> Result<f64>;
fn minmax(self) -> (f64, usize, f64, usize);
fn lintrans(self) -> Vec<f64>;
fn sortf(self) -> Vec<f64>; }

Vector algebra on one or two vectors.

Required methods

fn dotp(self, v: &[f64]) -> f64

Scalar product of two vectors

fn vsub(self, v: &[f64]) -> Vec<f64>

Vector subtraction

fn vadd(self, v: &[f64]) -> Vec<f64>

Vector addition

fn vmag(self) -> f64

Vector magnitude

fn vdist(self, v: &[f64]) -> f64

Euclidian distance between two points

fn smult(self, s: f64) -> Vec<f64>

Scalar multiplication

fn sadd(self, s: f64) -> Vec<f64>

Scalar addition to vector

fn vunit(self) -> Vec<f64>

Unit vector

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

Correlation

fn kendalcorr(self, v: &[f64]) -> Result<f64>

Kendall's tau-b (rank order) correlation

fn spearmancorr(self, v: &[f64]) -> Result<f64>

Spearman's rho (rank differences) correlation

fn autocorr(self) -> Result<f64>

Autocorrelation

fn minmax(self) -> (f64, usize, f64, usize)

Minimum, minimum's index, maximum, maximum's index.

fn lintrans(self) -> Vec<f64>

Linear transformation to [0,1]

fn sortf(self) -> Vec<f64>

Sorted vector

Loading content...

Implementations on Foreign Types

impl<'_> Vectors for &'_ [f64][src]

fn smult(self, s: f64) -> Vec<f64>[src]

Scalar multiplication of a vector, creates new vec

fn sadd(self, s: f64) -> Vec<f64>[src]

Scalar addition to a vector, creates new vec

fn dotp(self, v: &[f64]) -> f64[src]

Scalar product of two f64 slices.
Must be of the same length - no error checking for speed

fn vsub(self, v: &[f64]) -> Vec<f64>[src]

Vector subtraction, creates a new Vec result

fn vadd(self, v: &[f64]) -> Vec<f64>[src]

Vector addition, creates a new Vec result

fn vdist(self, v: &[f64]) -> f64[src]

Euclidian distance between two n dimensional points (vectors).
Slightly faster than vsub followed by vmag, as both are done in one loop

fn vmag(self) -> f64[src]

Vector magnitude

fn vunit(self) -> Vec<f64>[src]

Unit vector - creates a new one

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

Correlation coefficient of a sample of two f64 variables.

Example

use rstats::Vectors;
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.correlation(&v2).unwrap(),-1_f64);

fn kendalcorr(self, v: &[f64]) -> Result<f64>[src]

Kendall Tau-B correlation coefficient of a sample of two f64 variables. Defined by: tau = (conc - disc) / sqrt((conc + disc + tiesx) * (conc + disc + tiesy)) This is the simplest implementation with no sorting.

Example

use rstats::Vectors;
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.kendalcorr(&v2).unwrap(),-1_f64);

fn spearmancorr(self, v: &[f64]) -> Result<f64>[src]

Spearman rho correlation coefficient of a sample of two f64 variables. This is the simplest implementation with no sorting.

Example

use rstats::Vectors;
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.spearmancorr(&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::Vectors;
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);

fn minmax(self) -> (f64, usize, f64, usize)[src]

Finds minimum, minimum's index, maximum, maximum's index of &f64 Here self is usually some data, rather than a vector

fn lintrans(self) -> Vec<f64>[src]

Linear transform to interval [0,1]

fn sortf(self) -> Vec<f64>[src]

Sorted vector

Loading content...

Implementors

Loading content...