Trait rstats::VecVec[][src]

pub trait VecVec<T> {
Show 18 methods fn acentroid(self) -> Vec<f64>;
fn gcentroid(self) -> Vec<f64>;
fn hcentroid(self) -> Vec<f64>;
fn firstpoint(self) -> Vec<f64>;
fn distsums(self) -> Vec<f64>;
fn medout(self) -> MinMax<f64>;
fn distsuminset(self, indx: usize) -> f64;
fn nxmember(self, indx: usize) -> Vec<f64>;
fn nxnonmember(self, p: &[f64]) -> Vec<f64>;
fn eccmember(self, indx: usize) -> Vec<f64>;
fn eccnonmember(self, p: &[f64]) -> Vec<f64>;
fn eccentricities(self) -> Vec<Vec<f64>>;
fn exacteccs(self, eps: f64) -> Vec<Vec<f64>>;
fn eccinfo(self, eps: f64) -> (MStats, Med, MinMax<f64>)
    where
        Vec<f64>: FromIterator<f64>
;
fn emedoid(self, eps: f64) -> MinMax<f64>
    where
        Vec<f64>: FromIterator<f64>
;
fn sortedeccs(self, ascending: bool, eps: f64) -> (Vec<f64>, Vec<f64>);
fn gmedian(self, eps: f64) -> Vec<f64>;
fn smedian(self, eps: f64) -> Vec<f64>;
}
Expand description

Methods applicable to a single argument: a vector of vectors of generic end type. Operations on a set of multidimensional vectors.

Required methods

Arithmetic Centre = euclidian mean of a set of points

Geometric Centroid

Harmonic Centroid = harmonic mean of a set of points

Possible first iteration point for geometric medians

Sums of distances from each point to all other points

Medoid distance, its index, outlier distance, its index

Fast sums of distances from each point to all other points

Next approx gm computed at a member point given by its indx

Next approx gm computed at a nonmember point p

Estimated ecentricity vector from a member point given by its indx to gm

Estimated eccentricity vector from a non member point

Estimated eccentricity vectors from each member point

Exact eccentricity vectors from each member point by first finding the gm. As well as being more accurate, it is usually faster than eccentricities above, especially for large numbers of points.

Median and quartiles of eccentricities (new robust measure of spread of a multivariate sample)

Medoid and Outlier as defined by eccentricities.

Returns ( gm, sorted eccentricities magnitudes )

Improved Weizsfeld’s Algorithm for geometric median, to accuracy eps New algorithm for geometric median, to accuracy eps

Secant method geometric median

Implementations on Foreign Types

acentroid = simple multidimensional arithmetic mean

Example
use rstats::{Vecg,VecVec,VecVecg,genvec};
let pts = genvec(15,15,255,30); 
let dist = pts.distsum(&pts.acentroid());
assert_eq!(dist, 4.14556218326653_f64);

gcentroid = multidimensional geometric mean

Example
use rstats::{Vecg,VecVec,VecVecg,genvec};
let pts = genvec(15,15,255,30);
let centre = pts.gcentroid();
let dist = pts.distsum(&centre);
assert_eq!(dist,4.897594485332543_f64);

hcentroid = multidimensional harmonic mean

Example
use rstats::{Vecg,VecVec,VecVecg,genvec};
let pts = genvec(15,15,255,30);
let centre = pts.hcentroid();
let dist = pts.distsum(&centre);
assert_eq!(dist,5.1272881071877014_f64);

For each member point, gives its sum of distances to all other points and their MinMax

The sum of distances from one member point, given by its indx, to all the other points in self. For all the points, use more efficient distsums.

Medoid and Outlier (Medout) Medoid is the member point (point belonging to the set of points self), which has the least sum of distances to all other points. Outlier is the point with the greatest sum of distances. In other words, they are the members nearest and furthest from the geometric median. Returns struct MinMax{min,minindex,max,maxindex}

Example
use rstats::{Vecg,VecVec,VecVecg,genvec};
let pts = genvec(15,15,255,30);
let mm = pts.medout();
assert_eq!(mm.min,4.812334638782327_f64);

Finds approximate vectors from each member point towards the geometric median. Twice as fast as doing them individually, using symmetry.

Exact eccentricity vectors from all member points by first finding the Geometric Median. Usually faster than the approximate eccentricities above, especially when there are many points.

Estimated (computed) eccentricity vector for a member point. It points towards the geometric median. The true geometric median is as yet unknown. The true geometric median would return zero vector. The member point in question is specified by its index indx. This function is suitable for a single member point. When eccentricities of all the points are wanted, use exacteccs above.

Estimated (computed) eccentricity vector for a non member point. The true geometric median is as yet unknown. Returns the eccentricity vector. The true geometric median would return zero vector. This function is suitable for a single non-member point.

Mean and Std (in MStats struct), Median and quartiles (in Med struct), Median and Outlier (in MinMax struct) of scalar eccentricities of points in self. These are new robust measures of a cloud of multidimensional points (or multivariate sample).

GM and sorted eccentricities magnitudes. Describing a set of points self in n dimensions

Eccentricities of Medoid and Outlier.
Same as just the third element of a tuple returned by eccinfo

Example
use rstats::{Vecg,VecVec,genvec};
pub const EPS:f64 = 1e-7;
let d = 6_usize;
let pt = genvec(d,24,7,13); // random test data 5x20
let mm = pt.emedoid(EPS);
assert_eq!(mm.minindex,10); // index of e-medoid
assert_eq!(mm.maxindex,20);  // index of e-outlier

Initial (first) point for geometric medians. Same as eccnonmember(‘origin’) but saving the subtractions of zeroes.

Example
use rstats::{Vecg,VecVec,VecVecg,genvec};
let pts = genvec(15,15,255,30); 
let dist = pts.distsum(&pts.firstpoint());
assert_eq!(dist,4.132376831171272_f64);

Next approximate gm computed from a member point
specified by its index indx to self.

Next approximate gm computed from a non-member point p

Geometric Median (gm) is the point that minimises the sum of distances to a given set of points. It has (provably) only vector iterative solutions. Search methods are slow and difficult in highly dimensional space. Weiszfeld’s fixed point iteration formula had known problems with sometimes failing to converge. Especially, when the points are dense in the close proximity of the gm, or gm coincides with one of them.
However, these problems are fixed in my new algorithm here.
There will eventually be a multithreaded version.

Secant recovery from divergence for finding the geometric median. Initialised with first two points: the origin and the acentroid.

Implementors