Medians

GitHub last commit crates.io crates.io docs.rs

Fast new algorithm(s) for finding 1d medians, implemented in Rust.

Usage

rust use medians::{Med,MStats,Median};

Introduction

Finding the medians is a common task in statistics and general data analysis. At least it should be, if only it would not take so long. We argue in rstats that using the Geometric Median is the most stable way to characterise multidimensional data (nd). That leaves the one dimensional (1d) medians, addressed here. Medians are more stable measure of central tendency than means but they are not used nearly enough. One suspects that this is mostly due to being slower to compute than the arithmetic mean.

The Algorithms

Structs

Trait Median

rust /// Finding 1D medians, quartiles, and MAD (median of absolute differences) pub trait Median { /// Finds the median of `&[T]`, fast fn median(self) -> f64; /// Median of absolute differences (MAD). fn mad(self,median:f64) -> f64; /// Median and MAD. fn medstats(self) -> MStats; /// Median, quartiles, MAD, Stderr. fn medinfo(self) -> Med; }

Release Notes

Version 1.0.6 - Updated to times 1.0.4. Changed the comparison test accordingly.

Version 1.0.5 - Simplification. Deleted unnecessary w_median. Simplified error test. Updated dev-dependencies ran 1.0.3 and times 1.0.3.

Version 1.0.4 - Updated dependency indxvec v.1.4.2.

Version 1.0.3 - Added ratio mad/median (standard error) to struct Med and improved its Display.

Version 1.0.2 - Removed unnecessary extra reference from method median.

Version 1.0.1 - Added for convenience struct MStats and method medstats returning it. It holds here the median and MAD. More generally, any centre and dispersion. Moved the low level and private functions to module algos.rs. Updated times dev-dependency.

Version 1.0.0 - Updated to the latest indxvec dependency, v. 1.2.11. Added times crate for timing comparison test.

Version 0.1.2 - The public methods are now in trait Median.