Trait rstats::Medianf64

source ·
pub trait Medianf64 {
    // Required methods
    fn median(self) -> Result<f64, MedError<String>>;
    fn zeromedian(self) -> Result<Vec<f64, Global>, MedError<String>>;
    fn mediancorr(self, v: &[f64]) -> Result<f64, MedError<String>>;
    fn mad(self, med: f64) -> Result<f64, MedError<String>>;
    fn medstats(self) -> Result<MStats, MedError<String>>;
}
Expand description

Fast 1D f64 medians and associated information and tasks

Required Methods§

source

fn median(self) -> Result<f64, MedError<String>>

Finds the median, fast.

source

fn zeromedian(self) -> Result<Vec<f64, Global>, MedError<String>>

Zero median data produced by finding and subtracting the median.

source

fn mediancorr(self, v: &[f64]) -> Result<f64, MedError<String>>

Median correlation = cosine of an angle between two zero median vecs

source

fn mad(self, med: f64) -> Result<f64, MedError<String>>

Median of absolute differences (MAD).

source

fn medstats(self) -> Result<MStats, MedError<String>>

Median and MAD.

Implementations on Foreign Types§

source§

impl Medianf64 for &[f64]

source§

fn median(self) -> Result<f64, MedError<String>>

Returns single f64 number even for even medians. Non destructive.

source§

fn zeromedian(self) -> Result<Vec<f64, Global>, MedError<String>>

Zero median data produced by subtracting the median. Analogous to zero mean data when subtracting the mean.

source§

fn mediancorr(self, v: &[f64]) -> Result<f64, MedError<String>>

We define median based correlation as cosine of an angle between two zero median vectors (analogously to Pearson’s zero mean vectors)

Example
use medians::Medianf64;
let v1 = vec![1_f64,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.];
let v2 = vec![14_f64,1.,13.,2.,12.,3.,11.,4.,10.,5.,9.,6.,8.,7.];
assert_eq!(v1.mediancorr(&v2).unwrap(),-0.1076923076923077);
source§

fn mad(self, med: f64) -> Result<f64, MedError<String>>

Data dispersion estimator MAD (Median of Absolute Differences). MAD is more stable than standard deviation and more general than quartiles. When argument med is the median, it is the most stable measure of data dispersion.

source§

fn medstats(self) -> Result<MStats, MedError<String>>

Centre and dispersion defined by median

Implementors§