malevich 1.24.1

Terminal plotting: a small grammar of marks, honest axes, millions of points
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! The empirical cumulative distribution function.

/// The ECDF of `values`: sorted finite values paired with the fraction of the data
/// at or below each. Feeds a step line — see [`crate::ecdf`].
///
/// Returns empty vectors when nothing is finite.
pub fn ecdf(values: &[f64]) -> (Vec<f64>, Vec<f64>) {
    let mut sorted: Vec<f64> = values.iter().copied().filter(|v| v.is_finite()).collect();
    sorted.sort_by(f64::total_cmp);
    let n = sorted.len() as f64;
    let fractions = (1..=sorted.len()).map(|rank| rank as f64 / n).collect();
    (sorted, fractions)
}

#[cfg(test)]
#[path = "tests/ecdf_tests.rs"]
mod tests;