Trait indxvec::Indices

source ·
pub trait Indices {
    // Required methods
    fn invindex(self) -> Vec<usize>;
    fn complindex(self) -> Vec<usize>;
    fn unindex<T>(self, v: &[T], ascending: bool) -> Vec<T>
       where T: Clone;
    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 indices of Vec<usize> type.

Required Methods§

source

fn invindex(self) -> Vec<usize>

Invert an index - turns a sort order into rank order and vice-versa

source

fn complindex(self) -> Vec<usize>

complement of an index - reverses the ranking order

source

fn unindex<T>(self, v: &[T], ascending: bool) -> Vec<T>
where T: Clone,

Collect values from v in the order of indices in self.

source

fn ucorrelation(self, v: &[usize]) -> f64

Correlation coefficient of two &usize slices. Pearsons on raw data, Spearman’s when applied to ranks.

source

fn indx_to_f64(self) -> Vec<f64>

Potentially useful clone-recast of &usize to Vec

Provided Methods§

source

fn newindex(n: usize) -> Vec<usize>

Indices::newindex(n) creates a new index without rePartialOrdering

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Indices for &[usize]

source§

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 unindex<T>(self, v: &[T], ascending: bool) -> Vec<T>
where T: Clone,

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.

source§

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

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).

source§

fn indx_to_f64(self) -> Vec<f64>

Potentially useful clone-recast of &usize to Vec

Implementors§