Skip to main content

numeric

Function numeric 

Source
pub fn numeric(values: &mut [f64])
Expand description

Put a numeric sample in ascending order, in place.

A sample is not a collection a person reads item by item: it is ordered so that its order statistics — a median, a quantile, the bounds of a bootstrap interval — can be read off it. It still has exactly one order, IEEE 754’s total order, in which every value, both zeros and a NaN included, has one fixed place, so the result never depends on the order the values arrived in. It is written here, once, instead of as a comparator beside every piece of arithmetic that needs one.

use majordomus_cli::order::numeric;

let mut sample = vec![0.5, 0.0, 0.25, -0.0];
numeric(&mut sample);
assert_eq!(sample, [0.0, 0.0, 0.25, 0.5]);
assert!(sample[0].is_sign_negative(), "-0 has its own place, before +0");