pub trait Indices {
fn revindex(self) -> Vec<usize>;
fn invindex(self) -> Vec<usize>;
fn complindex(self) -> Vec<usize>;
fn unindex<T>(self, v: &[T], ascending: bool) -> Vec<T>
where
T: Copy;
fn unindexf64<T>(self, v: &[T], ascending: bool) -> Vec<f64>
where
T: Copy,
f64: From<T>;
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.
Collects values from v, as f64s, in the order given by self index.
fn ucorrelation(self, v: &[usize]) -> f64
fn ucorrelation(self, v: &[usize]) -> f64
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
Provided Methods
Implementations on Foreign Types
sourceimpl Indices for &[usize]
impl Indices for &[usize]
sourcefn revindex(self) -> Vec<usize>
fn revindex(self) -> Vec<usize>
Reverse an index slice by simple reverse iteration.
Creates a new Vec
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 unindexf64<T>(self, v: &[T], ascending: bool) -> Vec<f64> where
T: Copy,
f64: From<T>,
fn unindexf64<T>(self, v: &[T], ascending: bool) -> Vec<f64> where
T: Copy,
f64: From<T>,
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.
sourcefn complindex(self) -> Vec<usize>
fn complindex(self) -> Vec<usize>
Complement of an index (is symmetric) -
.complindex() toggles rank index between ascending/descending.
.complindex().invindex()
= .invindex().revindex()
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