pub trait Indices {
fn revindex(self) -> Vec<usize>;
fn invindex(self) -> Vec<usize>;
fn complindex(self) -> Vec<usize>;
fn unindex<T: Copy>(self, v: &[T], ascending: bool) -> Vec<T>;
fn unindexf64<T: Copy>(self, v: &[T], ascending: bool) -> Vec<f64>
where
f64: From<T>;
fn ucorrelation(self, v: &[usize]) -> f64;
fn indx_to_f64(self) -> Vec<f64>;
}
Expand description
Methods to manipulate indices of Vec<usize>
type.
Required methods
fn complindex(self) -> Vec<usize>
fn complindex(self) -> Vec<usize>
complement of the index - turns ranks from/to ascending/descending
Collect values from v
in the order of indices in self.
Collects values from v, as f64s, in the order given by self index.
Pearson’s correlation coefficient of two slices, typically the ranks.
fn indx_to_f64(self) -> Vec<f64>
fn indx_to_f64(self) -> Vec<f64>
Potentially useful clone-recast of &usize to Vec
Implementations on Foreign Types
Reverse an index slice by simple reverse iteration.
Creates a new Vec
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.
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.
Collects values from v in the order given by self index
and converts them to f64.
When ascending is false, collects in descending order.
It is used here by msort for ascending or descending sort.
Complement of an index (is symmetric) -
.complindex() toggles rank index between ascending/descending.
.complindex().invindex()
= .invindex().revindex()
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).
Potentially useful clone-recast of &usize to Vec