pub trait Indices {
fn invindex(self) -> Vec<usize>;
fn complindex(self) -> Vec<usize>;
fn unindex<T>(self, v: &[T], ascending: bool) -> Vec<T>
where
T: Copy;
fn ucorrelation(self, v: &[usize]) -> f64;
fn indx_to_f64(self) -> Vec<f64>;
fn newindex(n: usize) -> Vec<usize> { ... }
}Expand description
Methods to manipulate indices of Vec<usize> type.
Required Methods
Invert an index - turns a sort order into rank order and vice-versa
fn complindex(self) -> Vec<usize>
fn complindex(self) -> Vec<usize>
complement of an index - reverses the ranking order
Collect values from v in the order of indices in self.
fn ucorrelation(self, v: &[usize]) -> f64
fn ucorrelation(self, v: &[usize]) -> f64
Correlation coefficient of two &usize slices. Pearsons on raw data, Spearman’s when applied to ranks.
fn indx_to_f64(self) -> Vec<f64>
fn indx_to_f64(self) -> Vec<f64>
Potentially useful clone-recast of &usize to Vec
Provided Methods
Implementations on Foreign Types
sourceimpl Indices for &[usize]
impl Indices for &[usize]
sourcefn invindex(self) -> Vec<usize>
fn invindex(self) -> Vec<usize>
Inverts an index, eg. from sort index to ranks. This is a symmetric operation: any even number of applications gives the original index, odd number gives the inverted form.
sourcefn unindex<T>(self, v: &[T], ascending: bool) -> Vec<T> where
T: Copy,
fn unindex<T>(self, v: &[T], ascending: bool) -> Vec<T> where
T: Copy,
Collects values from v in the order given by self index.
When ascending is false, collects in descending order.
It is used here by msort for ascending or descending sort.
sourcefn complindex(self) -> Vec<usize>
fn complindex(self) -> Vec<usize>
Complement of an index (is symmetric) -
.complindex() toggles rank index between ascending/descending.
To toggle sort index between ascending/descending, use the general reversal revs:
ranks.complindex().invindex() = ranks.invindex().revs()
sourcefn ucorrelation(self, v: &[usize]) -> f64
fn ucorrelation(self, v: &[usize]) -> f64
Pearson’s correlation coefficient of two $[usize] slices.
When the inputs are ranks, then this gives Spearman’s correlation
of the original data. However, in general, any other ordinal measures
could be deployed (not just the ranks).
sourcefn indx_to_f64(self) -> Vec<f64>
fn indx_to_f64(self) -> Vec<f64>
Potentially useful clone-recast of &usize to Vec