pub trait VecVec<T> {
Show 36 methods
// Required methods
fn dvdt(self, centre: &[f64]) -> Result<Vec<f64>, RE>;
fn scalar_fn(
self,
f: impl Fn(&[T]) -> Result<f64, RE>
) -> Result<Vec<f64>, RE>;
fn vector_fn(
self,
f: impl Fn(&[T]) -> Result<Vec<f64>, RE>
) -> Result<Vec<Vec<f64>>, RE>;
fn radii(self, gm: &[f64]) -> Result<Vec<f64>, RE>;
fn column(self, cnum: usize) -> Vec<f64>;
fn transpose(self) -> Vec<Vec<f64>>;
fn normalize(self) -> Result<Vec<Vec<f64>>, RE>;
fn house_ur(self) -> Result<(TriangMat, TriangMat), RE>;
fn jointpdfn(self) -> Result<Vec<f64>, RE>;
fn jointentropyn(self) -> Result<f64, RE>;
fn dependencen(self) -> Result<f64, RE>;
fn crossfeatures(
self,
f: fn(_: &[T], _: &[T]) -> f64
) -> Result<TriangMat, RE>;
fn sumv(self) -> Vec<f64>;
fn acentroid(self) -> Vec<f64>;
fn par_acentroid(self) -> Vec<f64>;
fn gcentroid(self) -> Result<Vec<f64>, RE>;
fn hcentroid(self) -> Result<Vec<f64>, RE>;
fn distsums(self) -> Vec<f64>;
fn medout(self, gm: &[f64]) -> Result<MinMax<f64>, RE>;
fn radius(self, i: usize, gm: &[f64]) -> Result<f64, RE>;
fn eccinfo(self, gm: &[f64]) -> Result<(Params, Params, MinMax<f64>), RE>
where Vec<f64>: FromIterator<f64>;
fn quasimedian(self) -> Result<Vec<f64>, RE>;
fn sigvec(self, idx: &[usize]) -> Result<Vec<f64>, RE>;
fn madgm(self, gm: &[f64]) -> Result<f64, RE>;
fn stdgm(self, gm: &[f64]) -> Result<f64, RE>;
fn outer_hull(self, sqrads: &[f64], sindex: &[usize]) -> Vec<usize>;
fn inner_hull(self, sqrads: &[f64], sindex: &[usize]) -> Vec<usize>;
fn depth(self, descending_index: &[usize], p: &[f64]) -> Result<f64, RE>;
fn depth_ratio(self, descending_index: &[usize], p: &[f64]) -> f64;
fn hulls(self) -> (Vec<usize>, Vec<usize>);
fn gmerror(self, g: &[f64]) -> Result<f64, RE>;
fn gmedian(self, eps: f64) -> Vec<f64>;
fn par_gmedian(self, eps: f64) -> Vec<f64>;
fn gmparts(self, eps: f64) -> (Vec<f64>, f64);
fn covar(self, mid: &[f64]) -> Result<TriangMat, RE>;
fn serial_covar(self, mid: &[f64]) -> Result<TriangMat, RE>;
}
Expand description
Methods applicable to a slice of vectors of generic end type. Operations on a whole set of multidimensional vectors.
Required Methods§
sourcefn dvdt(self, centre: &[f64]) -> Result<Vec<f64>, RE>
fn dvdt(self, centre: &[f64]) -> Result<Vec<f64>, RE>
Linearly weighted approximate time series derivative at the last point (present time).
sourcefn scalar_fn(self, f: impl Fn(&[T]) -> Result<f64, RE>) -> Result<Vec<f64>, RE>
fn scalar_fn(self, f: impl Fn(&[T]) -> Result<f64, RE>) -> Result<Vec<f64>, RE>
Maps a scalar valued closure onto all vectors in self
sourcefn vector_fn(
self,
f: impl Fn(&[T]) -> Result<Vec<f64>, RE>
) -> Result<Vec<Vec<f64>>, RE>
fn vector_fn( self, f: impl Fn(&[T]) -> Result<Vec<f64>, RE> ) -> Result<Vec<Vec<f64>>, RE>
Maps vector valued closure onto all vectors in self and collects
sourcefn radii(self, gm: &[f64]) -> Result<Vec<f64>, RE>
fn radii(self, gm: &[f64]) -> Result<Vec<f64>, RE>
Exact radii magnitudes to all member points from the Geometric Median.
sourcefn normalize(self) -> Result<Vec<Vec<f64>>, RE>
fn normalize(self) -> Result<Vec<Vec<f64>>, RE>
Normalize columns, so that they are all unit vectors
sourcefn house_ur(self) -> Result<(TriangMat, TriangMat), RE>
fn house_ur(self) -> Result<(TriangMat, TriangMat), RE>
Householder’s method returning matrices (U,R)
sourcefn jointpdfn(self) -> Result<Vec<f64>, RE>
fn jointpdfn(self) -> Result<Vec<f64>, RE>
Joint probability density function of n matched slices of the same length
sourcefn jointentropyn(self) -> Result<f64, RE>
fn jointentropyn(self) -> Result<f64, RE>
Joint entropy between a set of vectors of the same length
sourcefn dependencen(self) -> Result<f64, RE>
fn dependencen(self) -> Result<f64, RE>
Dependence (component wise) of a set of vectors.
sourcefn crossfeatures(self, f: fn(_: &[T], _: &[T]) -> f64) -> Result<TriangMat, RE>
fn crossfeatures(self, f: fn(_: &[T], _: &[T]) -> f64) -> Result<TriangMat, RE>
Binary relations between columns of self
sourcefn par_acentroid(self) -> Vec<f64>
fn par_acentroid(self) -> Vec<f64>
Multithreaded Arithmetic Centre = euclidian mean of a set of points
sourcefn hcentroid(self) -> Result<Vec<f64>, RE>
fn hcentroid(self) -> Result<Vec<f64>, RE>
Harmonic Centroid = harmonic mean of a set of points
sourcefn medout(self, gm: &[f64]) -> Result<MinMax<f64>, RE>
fn medout(self, gm: &[f64]) -> Result<MinMax<f64>, RE>
Medoid distance, its index, outlier distance, its index
sourcefn radius(self, i: usize, gm: &[f64]) -> Result<f64, RE>
fn radius(self, i: usize, gm: &[f64]) -> Result<f64, RE>
Radius of a point specified by its subscript.
sourcefn eccinfo(self, gm: &[f64]) -> Result<(Params, Params, MinMax<f64>), RE>
fn eccinfo(self, gm: &[f64]) -> Result<(Params, Params, MinMax<f64>), RE>
Arith mean and std (in Params struct), Median and mad, Medoid and Outlier (in MinMax struct)
sourcefn quasimedian(self) -> Result<Vec<f64>, RE>
fn quasimedian(self) -> Result<Vec<f64>, RE>
Quasi median, recommended only for comparison purposes
sourcefn sigvec(self, idx: &[usize]) -> Result<Vec<f64>, RE>
fn sigvec(self, idx: &[usize]) -> Result<Vec<f64>, RE>
Proportional projections on each +/- axis (by hemispheres)
sourcefn madgm(self, gm: &[f64]) -> Result<f64, RE>
fn madgm(self, gm: &[f64]) -> Result<f64, RE>
madgm, median of radii from geometric median: stable nd data spread estimator
sourcefn stdgm(self, gm: &[f64]) -> Result<f64, RE>
fn stdgm(self, gm: &[f64]) -> Result<f64, RE>
stdgm mean of radii from gm: nd data spread estimator
sourcefn outer_hull(self, sqrads: &[f64], sindex: &[usize]) -> Vec<usize>
fn outer_hull(self, sqrads: &[f64], sindex: &[usize]) -> Vec<usize>
Outer hull subscripts from their square radii and their sort index.
sourcefn inner_hull(self, sqrads: &[f64], sindex: &[usize]) -> Vec<usize>
fn inner_hull(self, sqrads: &[f64], sindex: &[usize]) -> Vec<usize>
Inner hull subscripts from their square radii and their sort index.
sourcefn depth(self, descending_index: &[usize], p: &[f64]) -> Result<f64, RE>
fn depth(self, descending_index: &[usize], p: &[f64]) -> Result<f64, RE>
Measure of likelihood of zero median point p belonging to zero median data cloud self
.
sourcefn depth_ratio(self, descending_index: &[usize], p: &[f64]) -> f64
fn depth_ratio(self, descending_index: &[usize], p: &[f64]) -> f64
The proportion of points outside of the normal plane through p
sourcefn hulls(self) -> (Vec<usize>, Vec<usize>)
fn hulls(self) -> (Vec<usize>, Vec<usize>)
Collects indices of outer and inner hull points, from zero median data
sourcefn par_gmedian(self, eps: f64) -> Vec<f64>
fn par_gmedian(self, eps: f64) -> Vec<f64>
Parallel (multithreaded) implementation of Geometric Median. Possibly the fastest you will find.
sourcefn gmparts(self, eps: f64) -> (Vec<f64>, f64)
fn gmparts(self, eps: f64) -> (Vec<f64>, f64)
Like gmedian
but returns also the sum of reciprocals of distances
Object Safety§
Implementations on Foreign Types§
source§impl<T> VecVec<T> for &[Vec<T>]where
T: Clone + PartialOrd + Sync + Into<f64>,
Vec<Vec<T>>: IntoParallelIterator,
Vec<T>: IntoParallelIterator,
impl<T> VecVec<T> for &[Vec<T>]where
T: Clone + PartialOrd + Sync + Into<f64>,
Vec<Vec<T>>: IntoParallelIterator,
Vec<T>: IntoParallelIterator,
source§fn dvdt(self, centre: &[f64]) -> Result<Vec<f64>, RE>
fn dvdt(self, centre: &[f64]) -> Result<Vec<f64>, RE>
Linearly weighted approximate time series derivative at the last point (present time). Weighted average (backwards half filter), minus the median.
source§fn scalar_fn(self, f: impl Fn(&[T]) -> Result<f64, RE>) -> Result<Vec<f64>, RE>
fn scalar_fn(self, f: impl Fn(&[T]) -> Result<f64, RE>) -> Result<Vec<f64>, RE>
Maps scalar valued closure onto all vectors in self and collects
source§fn vector_fn(
self,
f: impl Fn(&[T]) -> Result<Vec<f64>, RE>
) -> Result<Vec<Vec<f64>>, RE>
fn vector_fn( self, f: impl Fn(&[T]) -> Result<Vec<f64>, RE> ) -> Result<Vec<Vec<f64>>, RE>
Maps vector valued closure onto all vectors in self and collects
source§fn radii(self, gm: &[f64]) -> Result<Vec<f64>, RE>
fn radii(self, gm: &[f64]) -> Result<Vec<f64>, RE>
Exact radii magnitudes to all member points from the Geometric Median.
More accurate and usually faster as well than the approximate eccentricities
above,
especially when there are many points.
source§fn normalize(self) -> Result<Vec<Vec<f64>>, RE>
fn normalize(self) -> Result<Vec<Vec<f64>>, RE>
Normalize columns, so that they become unit row vectors
source§fn house_ur(self) -> Result<(TriangMat, TriangMat), RE>
fn house_ur(self) -> Result<(TriangMat, TriangMat), RE>
Householder’s method returning triangular matrices (U’,R), where U are the reflector generators for use by house_uapply(m). R is the upper triangular decomposition factor. Here both U and R are returned for convenience in their transposed lower triangular forms. Transposed input self for convenience, so that original columns get accessed easily as rows.
source§fn jointpdfn(self) -> Result<Vec<f64>, RE>
fn jointpdfn(self) -> Result<Vec<f64>, RE>
Joint probability density function of n matched slices of the same length
source§fn dependencen(self) -> Result<f64, RE>
fn dependencen(self) -> Result<f64, RE>
Dependence (component wise) of a set of vectors.
i.e. dependencen
returns 0 iff they are statistically independent
bigger values when they are dependentent
source§fn crossfeatures(self, f: fn(_: &[T], _: &[T]) -> f64) -> Result<TriangMat, RE>
fn crossfeatures(self, f: fn(_: &[T], _: &[T]) -> f64) -> Result<TriangMat, RE>
Flattened lower triangular part of a symmetric matrix for vectors in self.
The upper triangular part can be trivially generated for all j>i by: c(j,i) = c(i,j).
Applies closure f to compute a scalar binary relation between all pairs of vector
components of self.
The closure typically invokes one of the methods from Vecg trait (in vecg.rs),
such as dependencies.
Example call: pts.transpose().crossfeatures(|v1,v2| v1.mediancorrf64(v2)?)?
computes median correlations between all column vectors (features) in pts.
source§fn par_acentroid(self) -> Vec<f64>
fn par_acentroid(self) -> Vec<f64>
multithreaded acentroid = multidimensional arithmetic mean
source§fn distsums(self) -> Vec<f64>
fn distsums(self) -> Vec<f64>
For each member point, gives its sum of distances to all other points and their MinMax
source§fn medout(self, gm: &[f64]) -> Result<MinMax<f64>, RE>
fn medout(self, gm: &[f64]) -> Result<MinMax<f64>, RE>
Points nearest and furthest from the geometric median. Returns struct MinMax{min,minindex,max,maxindex}
source§fn radius(self, i: usize, gm: &[f64]) -> Result<f64, RE>
fn radius(self, i: usize, gm: &[f64]) -> Result<f64, RE>
Radius of a point specified by its subscript.
source§fn eccinfo(self, gm: &[f64]) -> Result<(Params, Params, MinMax<f64>), RE>
fn eccinfo(self, gm: &[f64]) -> Result<(Params, Params, MinMax<f64>), RE>
Arith mean and std (in Params struct), Median and MAD (in another Params struct), Medoid and Outlier (in MinMax struct) of scalar radii of points in self. These are new robust measures of a cloud of multidimensional points (or multivariate sample).
source§fn quasimedian(self) -> Result<Vec<f64>, RE>
fn quasimedian(self) -> Result<Vec<f64>, RE>
Quasi median, recommended only for comparison purposes
source§fn sigvec(self, idx: &[usize]) -> Result<Vec<f64>, RE>
fn sigvec(self, idx: &[usize]) -> Result<Vec<f64>, RE>
Proportional projections on each +/- axis (by hemispheres).
Adds only points that are specified in idx.
Self should be zero median vectors, previously obtained by self.translate(&gm)
.
The result is normalized to unit vector.
source§fn madgm(self, gm: &[f64]) -> Result<f64, RE>
fn madgm(self, gm: &[f64]) -> Result<f64, RE>
madgm median of distances from gm: stable nd data spread measure
source§fn stdgm(self, gm: &[f64]) -> Result<f64, RE>
fn stdgm(self, gm: &[f64]) -> Result<f64, RE>
stdgm mean of distances from gm: nd data spread measure, aka nd standard deviation
source§fn outer_hull(self, sqrads: &[f64], sindex: &[usize]) -> Vec<usize>
fn outer_hull(self, sqrads: &[f64], sindex: &[usize]) -> Vec<usize>
Outer hull subscripts from their square radii and their sort index
source§fn inner_hull(self, sqrads: &[f64], sindex: &[usize]) -> Vec<usize>
fn inner_hull(self, sqrads: &[f64], sindex: &[usize]) -> Vec<usize>
Inner hull points from their square radii and their sort index
source§fn depth(self, descending_index: &[usize], p: &[f64]) -> Result<f64, RE>
fn depth(self, descending_index: &[usize], p: &[f64]) -> Result<f64, RE>
Likelihood of zero median point p belonging to zero median data cloud self
,
based on the points outside of the normal plane through p.
Returns the sum of unit vectors of its outside points, projected onto unit p.
Index should be in the descending order of magnitudes of self points (for efficiency).
source§fn depth_ratio(self, descending_index: &[usize], p: &[f64]) -> f64
fn depth_ratio(self, descending_index: &[usize], p: &[f64]) -> f64
Likelihood of zero median point p belonging to zero median data cloud self
,
based on the proportion of points outside of the normal plane through p.
Index should be in the descending order of magnitudes of self points (for efficiency).
source§fn hulls(self) -> (Vec<usize>, Vec<usize>)
fn hulls(self) -> (Vec<usize>, Vec<usize>)
Collects indices of inner hull and outer hull, from zero median points in self.
We put a plane trough data point A, normal to its zero median vector a.
B is an inner hull point, when it lies inside all other points’ normal planes.
C is an outer hull point, when there is no other point outside its own normal plane.
B can belong to both hulls, as when all the points lie on a hyper-sphere around gm.
The testing is done in increasing (decreasing) radius order.
B lies outside the normal plane of a, when its projection onto unit a exceeds
|a|: |b|cos(θ) > |a| => a*b > |a|^2
,
such B immediately fails as a candidate for the inner hull.
Using square magnitudes, |a|^2
saves taking square roots and dividing the dot product by |a|.
Similarly for the outer hull, where A and B simply swap roles.
source§fn gmedian(self, eps: f64) -> Vec<f64>
fn gmedian(self, eps: f64) -> Vec<f64>
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 has 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.
The sum of reciprocals is strictly increasing and so is used here as
easy to evaluate termination condition.
source§fn par_gmedian(self, eps: f64) -> Vec<f64>
fn par_gmedian(self, eps: f64) -> Vec<f64>
Parallel (multithreaded) implementation of Geometric Median. Possibly the fastest you will find.
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 hyper space.
Weiszfeld’s fixed point iteration formula has known problems and sometimes fails to converge.
Specifically, when the points are dense in the close proximity of the gm, or gm coincides with one of them.
However, these problems are solved in my new algorithm here.
The sum of reciprocals is strictly increasing and so is used to easily evaluate the termination condition.
source§fn gmparts(self, eps: f64) -> (Vec<f64>, f64)
fn gmparts(self, eps: f64) -> (Vec<f64>, f64)
Like gmedian
but returns also the sum of reciprocals.
source§fn covar(self, mid: &[f64]) -> Result<TriangMat, RE>
fn covar(self, mid: &[f64]) -> Result<TriangMat, RE>
Symmetric covariance matrix. Becomes comediance when argument mid
is the geometric median instead of the centroid.
The indexing is always in this order: (row,column) (left to right, top to bottom).
The items are flattened into a single vector in this order.