[][src]Trait rstats::Vectors

pub trait Vectors {
    fn dotp(&self, v: &[f64]) -> f64;
fn vsub(&self, v: &[f64]) -> Vec<f64>;
fn vadd(&self, v: &[f64]) -> Vec<f64>;
fn vmag(&self) -> f64;
fn vdist(&self, v: &[f64]) -> f64;
fn smult(&self, s: f64) -> Vec<f64>;
fn vunit(&self) -> Vec<f64>;
fn medoid(&self, d: usize) -> Result<(usize, f64)>;
fn distsum(&self, d: usize, v: &[f64]) -> f64;
fn betterpoint(&self, d: usize, v: &[f64]) -> Vec<f64>;
fn firstpoint(&self, d: usize, indx: usize) -> Vec<f64>;
fn gmedian(&self, d: usize, eps: f64) -> Result<(f64, Vec<f64>)>; }

Implementing basic vector algebra.

Required methods

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

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

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

fn vmag(&self) -> f64

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

fn smult(&self, s: f64) -> Vec<f64>

fn vunit(&self) -> Vec<f64>

fn medoid(&self, d: usize) -> Result<(usize, f64)>

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

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

fn firstpoint(&self, d: usize, indx: usize) -> Vec<f64>

fn gmedian(&self, d: usize, eps: f64) -> Result<(f64, Vec<f64>)>

Loading content...

Implementations on Foreign Types

impl<'_> Vectors for &'_ [f64][src]

fn smult(&self, s: f64) -> Vec<f64>[src]

Scalar multiplication of a vector, creates new vec

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

Scalar product of two f64 slices.
Must be of the same length - no error checking for speed

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

Vector subtraction, creates a new Vec result

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

Vector addition, creates a new Vec result

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

Euclidian distance between two n dimensional points (vectors).
Slightly faster than vsub followed by vmag, as both are done in one loop

fn vmag(&self) -> f64[src]

Vector magnitude

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

Unit vector

fn medoid(&self, d: usize) -> Result<(usize, f64)>[src]

Medoid is a point in n-dimensional set of points with the least sum of distances to all others. This method returns an index to the start of medoid within a flat vector of d-dimensional points.
d is the number of dimensions = length of the slices. Set of points (slices) is held as one flat buff:&[f64].
This is faster than vec of vecs but users have to handle the indices.
Note: medoid computes each distance twice but it is probably faster than memoizing and looking them up,
unless the dimensionality is somewhat large

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

The sum of distances of all points contained in &self to given point v.
v which minimises this objective function is the Geometric Median.

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

Weiszfeld's formula for one iteration step in finding gmedian.
Has problems with choosing the starting point - may fail to converge

fn firstpoint(&self, d: usize, indx: usize) -> Vec<f64>[src]

My innovative first steps that guarantee good convergence

fn gmedian(&self, d: usize, eps: f64) -> Result<(f64, Vec<f64>)>[src]

Geometric Median is the point that minimises the sum of distances to a given set of points. This improved algorithm has guaranteed good convergence, as it will not approach any points in the set (which caused problems to Weiszfeld). eps controls the desired accuracy (low threshold on the improvements in the sum of distances)

Loading content...

Implementors

Loading content...