pub trait Indices {
// Required methods
fn invindex(self) -> Vec<usize>;
fn complindex(self) -> Vec<usize>;
fn select<T: Clone>(self, v: &[T]) -> Vec<T>;
fn unindex<T: Clone>(self, v: &[T], ascending: bool) -> Vec<T>;
fn ucorrelation(self, v: &[usize]) -> f64;
fn indx_to_f64(self) -> Vec<f64>;
// Provided method
fn newindex(n: usize) -> Vec<usize> { ... }
}Expand description
Methods to manipulate and apply indices of Vec<usize> type.
Required Methods§
Sourcefn invindex(self) -> Vec<usize>
fn invindex(self) -> Vec<usize>
Invert an index - turns a sort order into rank order and vice-versa
Sourcefn complindex(self) -> Vec<usize>
fn complindex(self) -> Vec<usize>
complement of an index - reverses the ranking order
Sourcefn unindex<T: Clone>(self, v: &[T], ascending: bool) -> Vec<T>
fn unindex<T: Clone>(self, v: &[T], ascending: bool) -> Vec<T>
Given a complete (sort) index, extracts indicated values from v
Sourcefn 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.
Sourcefn indx_to_f64(self) -> Vec<f64>
fn indx_to_f64(self) -> Vec<f64>
Potentially useful clone-recast of &usize to Vec
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Indices for &[usize]
impl Indices for &[usize]
Source§fn 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.
Source§fn select<T: Clone>(self, v: &[T]) -> Vec<T>
fn select<T: Clone>(self, v: &[T]) -> Vec<T>
Sequentially collects items from v, based on sorted (partial) list of subscripts.
Maintains the order of v, simply leaving out items not represented in the list.
Is useful for efficient projections to subspaces.
Source§fn unindex<T>(self, v: &[T], ascending: bool) -> Vec<T>where
T: Clone,
fn unindex<T>(self, v: &[T], ascending: bool) -> Vec<T>where
T: Clone,
Given a complete (sort) index, extracts indicated values from v.
When ascending is false, collects in the reverse order.
Used by msort for ascending or descending sort.
Source§fn 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()
Source§fn 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).