Function inc_stats::mode

source ·
pub fn mode<I>(data: I) -> Option<f64>where
    I: Iterator<Item = f64>,
Expand description

Get the mode of a set of data

If multiple modes exist, this returns the first element that reached the largest count. NaNs are ignored when computing the mode.

Examples:

let nums = [2.0, 4.0, 2.0];
let mode = inc_stats::mode(nums.iter().cloned());
assert_eq!(Some(2.0), mode);
let mode = inc_stats::mode(std::iter::empty());
assert!(mode.is_none());