[][src]Trait rstats::VecVec

pub trait VecVec {
    fn acentroid(self) -> Vec<f64>;
fn distances(self) -> Vec<f64>;
fn distsuminset(self, indx: usize) -> f64;
fn distsum(self, v: &[f64]) -> f64;
fn medoid(self) -> (f64, usize, f64, usize);
fn eccentricities(self) -> Vec<Vec<f64>>;
fn eccentrinset(self, indx: usize) -> f64;
fn veccentr(self, thisp: &[f64]) -> (f64, Vec<f64>);
fn ecc(self, v: &[f64]) -> f64;
fn mags(self) -> Vec<f64>;
fn scalarecc(self) -> Vec<f64>;
fn moe(self) -> Med;
fn emedoid(self) -> (f64, usize, f64, usize);
fn nmedian(self, eps: f64) -> Vec<f64>;
fn betterpoint(self, v: &[f64]) -> (f64, Vec<f64>);
fn trend(self, eps: f64, v: Vec<Vec<f64>>) -> Vec<f64>;
fn translate(self, m: &[f64]) -> Vec<Vec<f64>>; }

Methods applicable to sets of vectors

Required methods

fn acentroid(self) -> Vec<f64>

Centroid = euclidian mean of a set of points

fn distances(self) -> Vec<f64>

Sums of distances from each point to all other points

fn distsuminset(self, indx: usize) -> f64

Sum of distances from one point given by indx

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

Sum of distances from arbitrary point (v) to all the points in self

fn medoid(self) -> (f64, usize, f64, usize)

Medoid and Outlier (by distance) of a set of points

fn eccentricities(self) -> Vec<Vec<f64>>

Eccentricity vectors from each point

fn eccentrinset(self, indx: usize) -> f64

Ecentricity scalar measure of an internal point given by indx

fn veccentr(self, thisp: &[f64]) -> (f64, Vec<f64>)

Eccentricity scalar measure and vector of any point

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

Eccentricity scalar measure only, of any point

fn mags(self) -> Vec<f64>

magnitudes of a set of vectors

fn scalarecc(self) -> Vec<f64>

scaled magnitudes (typically of eccentricities measures)

fn moe(self) -> Med

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

fn emedoid(self) -> (f64, usize, f64, usize)

Medoid and Outlier as defined by eccentricities.

fn nmedian(self, eps: f64) -> Vec<f64>

Geometric median of a set

fn betterpoint(self, v: &[f64]) -> (f64, Vec<f64>)

Betterpoint gives new approximation to nmedian

fn trend(self, eps: f64, v: Vec<Vec<f64>>) -> Vec<f64>

Trend between two sets

fn translate(self, m: &[f64]) -> Vec<Vec<f64>>

Transform to zero median form. or subtract any other vector m

Loading content...

Implementations on Foreign Types

impl<'_> VecVec for &'_ [Vec<f64>][src]

fn acentroid(self) -> Vec<f64>[src]

Centroid = simple multidimensional arithmetic mean

Example

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

fn distances(self) -> Vec<f64>[src]

For each point, gives its sum of distances to all other points. This is the efficient workhorse of distances based analysis.

fn distsuminset(self, indx: usize) -> f64[src]

The sum of distances from a set point given by its indx to all the other points in self. This method is suitable for a single point. For all the points, use more efficient distances.

fn distsum(self, v: &[f64]) -> f64[src]

The sum of distances from any point v (typically not in self) to all the points in self.
Geometric Median is defined as the point v which minimises this function.

fn medoid(self) -> (f64, usize, f64, usize)[src]

Medoid is the point belonging to 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. This function returns a four-tuple:
(medoid_distance, medoid_index, outlier_distance, outlier_index). d is the number of dimensions = length of the point sub-slices. The entire set of points is held in one flat &[f64].
This is faster than vec of vecs but we have to handle the indices.

Example

use rstats::{Vectors,VecVec,functions::genvec};
let pts = genvec(15,15,255,30);
let (dm,_,_,_) = pts.medoid();
assert_eq!(dm,4.812334638782327_f64);

fn eccentricities(self) -> Vec<Vec<f64>>[src]

Eccentricity vector for each point. This is the efficient workhorse of eccentrities analysis.

fn eccentrinset(self, indx: usize) -> f64[src]

Scalar positive measure of not being a median for a point belonging to the set. The point is specified by its index indx. The median does not have to be known. The perfect median would return zero. This is suitable for a single point. When eccentricities of all the points are needed, use more efficient eccentricities.

fn veccentr(self, thisp: &[f64]) -> (f64, Vec<f64>)[src]

Returns (Measure, Eccentricity-Vector) of any point (typically one not belonging to the set). The first (scalar) part of the result is a positive measure of not being a median. The second part is the eccentricity vector, which always points towards the median. The vector is of particular value and interest. This function has no prior knowledge of the actual median.
This is suitable for a single point. When eccentricities of all the points are needed, use more efficient eccentricities.

fn ecc(self, v: &[f64]) -> f64[src]

This convenience wrapper calls veccentr and extracts just the eccentricity (residual error for median). Thus this method is the equivalent of eccentr but suited for any explicitly given point, typically not belonging to the set.
When the eccentricity vector is needed, use veccentr

fn mags(self) -> Vec<f64>[src]

Magnitudes of the vectors in self

fn scalarecc(self) -> Vec<f64>[src]

Scalar measures of eccentricity for the whole set. The output can be typically passed to median or minmax to find the Outlier and the Medoid.

fn moe(self) -> Med[src]

Median of eccentricities measures (MOE). This is a new robust measure of spread of multidimensional points (or multivariate sample).

fn emedoid(self) -> (f64, usize, f64, usize)[src]

Eccentricity defined Medoid and Outlier. This can give different results to medoid above, defined by sums of distances, especially for the outliers. See tests.rs.
Consider some point c and some other points, bunched up at a distance r from c. The sum of their distances will be n*r. Now, spread those points around a circle of radius r from c. The sum of their distances from c will remain the same but the eccentricity of c will be much reduced.

Example

use rstats::{Vectors,VecVec,functions::genvec};
let d = 6_usize;
let pt = genvec(d,24,7,13); // random test data 5x20
let (_medoideccentricity,medei,_outlierecccentricity,outei) = pt.emedoid();
assert_eq!(medei,10); // index of e-medoid
assert_eq!(outei,9);  // index of e-outlier

fn nmedian(self, eps: f64) -> Vec<f64>[src]

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 it coincides with one of them.
However, these problems are fixed in my new algorithm here.
There will eventually be a multithreaded version of nmedian.

Example

use rstats::{VecVec,functions::genvec};
let pt = genvec(15,15,255,30);
let gm = pt.nmedian(1e-5);
let error = pt.ecc(&gm);
assert_eq!(error,0.000004826966175302838_f64);

fn betterpoint(self, v: &[f64]) -> (f64, Vec<f64>)[src]

betterpoint is called by nmedian. Scaling by rsum is left as the final step at calling level, in order to facilitate data parallelism.

fn trend(self, eps: f64, v: Vec<Vec<f64>>) -> Vec<f64>[src]

Trend computes the vector connecting the geometric medians of two sets of multidimensional points. This is a robust relationship between two unordered multidimensional sets. The two sets have to be in the same space but can have different numbers of points.

fn translate(self, m: &[f64]) -> Vec<Vec<f64>>[src]

Translates the whole set by vector -m. Returns Vec of Vecs. When m is set to the geometric median, this produces the zero median form. The geometric median is invariant with respect to rotation, unlike the often misguidedly used mean (acentroid here), or the quasi median, both of which depend on the choice of axis. The quasi-median is not even implemented by rstats.

Loading content...

Implementors

Loading content...