Trait rstats::Vecf64 [−][src]
pub trait Vecf64 {}Show methods
fn smult(self, s: f64) -> Vec<f64>; fn sadd(self, s: f64) -> Vec<f64>; fn dotp(self, v: &[f64]) -> f64; fn vinverse(self) -> Vec<f64>; fn cosine(self, _v: &[f64]) -> f64; fn vsub(self, v: &[f64]) -> Vec<f64>; fn negv(self) -> Vec<f64>; fn vadd(self, v: &[f64]) -> Vec<f64>; fn vmag(self) -> f64; fn vmagsq(self) -> f64; fn vdist(self, v: &[f64]) -> f64; fn vdistsq(self, v: &[f64]) -> f64; fn vunit(self) -> Vec<f64>; fn varea(self, v: &[f64]) -> f64; fn varc(self, v: &[f64]) -> f64; fn vsim(self, v: &[f64]) -> f64; fn vdisim(self, v: &[f64]) -> f64; fn correlation(self, _v: &[f64]) -> f64; fn kendalcorr(self, _v: &[f64]) -> f64; fn spearmancorr(self, _v: &[f64]) -> f64; fn kazutsugi(self) -> f64; fn autocorr(self) -> f64; fn minmax(self) -> (f64, usize, f64, usize); fn lintrans(self) -> Vec<f64>; fn binsearch(self, v: f64) -> usize; fn merge(self, v: &[f64]) -> Vec<f64>; fn merge_immutable(
self,
idx1: &[usize],
v2: &[f64],
idx2: &[usize]
) -> (Vec<f64>, Vec<usize>); fn merge_indices(self, idx1: &[usize], idx2: &[usize]) -> Vec<usize>; fn sortf(self) -> Vec<f64>; fn sortm(self, ascending: bool) -> Vec<f64>; fn mergerank(self) -> Vec<usize>; fn mergesort(self, i: usize, n: usize) -> Vec<usize>;
Expand description
Vector algebra on one or two vectors.
Required methods
fn varea(self, v: &[f64]) -> f64
[src]
fn varea(self, v: &[f64]) -> f64
[src]Area of parallelogram between two vectors (magnitude of cross product)
fn kazutsugi(self) -> f64
[src]
fn kazutsugi(self) -> f64
[src]Kazutsugi Spearman’s corelation against just five distances (to outcomes classes)
fn merge_immutable(
self,
idx1: &[usize],
v2: &[f64],
idx2: &[usize]
) -> (Vec<f64>, Vec<usize>)
[src]
fn merge_immutable(
self,
idx1: &[usize],
v2: &[f64],
idx2: &[usize]
) -> (Vec<f64>, Vec<usize>)
[src]Merges two sort indices, returns simply concatenated Vec
Implementations on Foreign Types
impl Vecf64 for &[f64]
[src]
impl Vecf64 for &[f64]
[src]fn dotp(self, v: &[f64]) -> f64
[src]
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 cosine(self, v: &[f64]) -> f64
[src]
fn cosine(self, v: &[f64]) -> f64
[src]Cosine of an angle between two vectors.
Example
use rstats::Vecf64; let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.]; let v2 = vec![14_f64,1.,13.,2.,12.,3.,11.,4.,10.,5.,9.,6.,8.,7.]; assert_eq!(v1.cosine(&v2),0.7517241379310344);
fn vdist(self, v: &[f64]) -> f64
[src]
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 vdistsq(self, v: &[f64]) -> f64
[src]
fn vdistsq(self, v: &[f64]) -> f64
[src]Euclidian distance squared between two n dimensional points (vectors).
Slightly faster than vsub followed by vmasq, as both are done in one loop
Same as vdist without taking the square root
fn varea(self, v: &[f64]) -> f64
[src]
fn varea(self, v: &[f64]) -> f64
[src]Area of a parallelogram between two vectors.
Same as the magnitude of their cross product |a ^ b| = |a||b|sin(theta).
Attains maximum |a|.|b|
when the vectors are othogonal.
fn varc(self, v: &[f64]) -> f64
[src]
fn varc(self, v: &[f64]) -> f64
[src]Area proportional to the swept arc up to angle theta.
Attains maximum of 2|a||b|
when the vectors have opposite orientations.
This is really |a||b|(1-cos(theta)) = 2|a||b|D
fn vsim(self, v: &[f64]) -> f64
[src]
fn vsim(self, v: &[f64]) -> f64
[src]We define vector similarity S in the interval [0,1] as S = (1+cos(theta))/2
fn vdisim(self, v: &[f64]) -> f64
[src]
fn vdisim(self, v: &[f64]) -> f64
[src]We define vector dissimilarity D in the interval [0,1] as D = 1-S = (1-cos(theta))/2
fn correlation(self, v: &[f64]) -> f64
[src]
fn correlation(self, v: &[f64]) -> f64
[src]Pearson’s correlation coefficient of a sample of two f64 variables.
Example
use rstats::Vecf64; let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.]; let v2 = vec![14_f64,1.,13.,2.,12.,3.,11.,4.,10.,5.,9.,6.,8.,7.]; assert_eq!(v1.correlation(&v2),-0.1076923076923077);
fn kendalcorr(self, v: &[f64]) -> f64
[src]
fn kendalcorr(self, v: &[f64]) -> 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::Vecf64; let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.]; let v2 = vec![14_f64,1.,13.,2.,12.,3.,11.,4.,10.,5.,9.,6.,8.,7.]; assert_eq!(v1.kendalcorr(&v2),-0.07692307692307693);
fn spearmancorr(self, v: &[f64]) -> f64
[src]
fn spearmancorr(self, v: &[f64]) -> f64
[src]Spearman rho correlation coefficient of two f64 variables. This is the simplest implementation with no sorting.
Example
use rstats::Vecf64; let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.]; let v2 = vec![14_f64,1.,13.,2.,12.,3.,11.,4.,10.,5.,9.,6.,8.,7.]; assert_eq!(v1.spearmancorr(&v2),-0.1076923076923077);
fn kazutsugi(self) -> f64
[src]
fn kazutsugi(self) -> f64
[src]Spearman correlation of five distances against Kazutsugi discrete outcomes [0.00,0.25,0.50,0.75,1.00], ranked as [4,3,2,1,0] (the order is swapped to penalise distances). The result is in the range [-1,1].
Example
use rstats::Vecf64; let v1:Vec<f64> = vec![4.,1.,2.,0.,3.]; assert_eq!(v1.kazutsugi(),0.3);
fn autocorr(self) -> f64
[src]
fn autocorr(self) -> f64
[src](Auto)correlation coefficient of pairs of successive values of (time series) f64 variable.
Example
use rstats::Vecf64; 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);
fn minmax(self) -> (f64, usize, f64, usize)
[src]
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 binsearch(self, v: f64) -> usize
[src]
fn binsearch(self, v: f64) -> usize
[src]Returns index to the first item that is strictly greater than v, using binary search of an ascending sorted list. When none are greater, returns self.len(). User must check for this index overflow: if the returned index == 0, then v was below the list, else use index-1 as a valid index to the last item that is less than or equal to v. This then is the right index to use for looking up cummulative probability density functions.
fn merge_immutable(
self,
idx1: &[usize],
v2: &[f64],
idx2: &[usize]
) -> (Vec<f64>, Vec<usize>)
[src]
fn merge_immutable(
self,
idx1: &[usize],
v2: &[f64],
idx2: &[usize]
) -> (Vec<f64>, Vec<usize>)
[src]Merges two ascending sorted vectors’ indices, returns concatenated Vec
fn merge_indices(self, idx1: &[usize], idx2: &[usize]) -> Vec<usize>
[src]
fn merge_indices(self, idx1: &[usize], idx2: &[usize]) -> Vec<usize>
[src]Merges indices of two already concatenated sorted vectors:
self is untouched, only sort indices are merged.
Used by mergesort
and merge_immutable
.
fn sortm(self, ascending: bool) -> Vec<f64>
[src]
fn sortm(self, ascending: bool) -> Vec<f64>
[src]Immutable sort. Returns new sorted vector, just like ‘sortf’ above but using our indexing ‘mergesort’ below. Simply passes the boolean flag ‘ascending’ onto ‘unindex’.
fn mergerank(self) -> Vec<usize>
[src]
fn mergerank(self) -> Vec<usize>
[src]Ranking of self by inverting the (merge) sort index.
Sort index is in sorted order, giving indices to the original data positions.
Ranking is in original data order, giving their positions in the sort index.
Thus they are in an inverse relationship, easily converted by .revindex()
Very fast ranking of many f64 items, ranking self
with only n*(log(n)+1) complexity.
fn mergesort(self, i: usize, n: usize) -> Vec<usize>
[src]
fn mergesort(self, i: usize, n: usize) -> Vec<usize>
[src]Doubly recursive non-destructive merge sort. The data is read-only, it is not moved or mutated.
Returns vector of indices to self from i to i+n, such that the indexed values are in sort order.
Thus we are moving only the index (key) values instead of the actual values.
fn sortf(self) -> Vec<f64>
[src]
fn sortf(self) -> Vec<f64>
[src]New sorted vector. Immutable sort.
Copies self and then sorts it in place, leaving self unchanged.
Calls mutsortf and that calls the standard self.sort_unstable_by.
Consider using our sortm
instead.