Skip to main content

median

Function median 

Source
pub fn median(values: &[f64]) -> Option<f64>
Expand description

Median of a slice of values.

Copies the input and sorts with f64::total_cmp (total, deterministic — see the module-level precondition note on NaN). For even n the median is the midpoint mean of the two central order statistics.

§Arguments

  • values — Sample values. Precondition: finite (callers enforce via crate::validation).

§Returns

Some(median), or None if values is empty.