Skip to main content

mode_in_place

Function mode_in_place 

Source
pub fn mode_in_place(values: &mut [f64]) -> Option<(f64, usize)>
Expand description

Mode — the most frequently occurring value, with its count.

Sorts the caller’s buffer in place (non-allocating) and scans for the longest run of bit-equal values. On a tie the smallest such value wins (deterministic, from the sorted order). None for an empty slice.

Floating-point mode compares exact equality, so it is meaningful for discrete/quantised data; for genuinely continuous data every value is typically unique and the count is 1 (the caller decides whether that is useful). NaN values sort to one end via partial_cmp and are grouped among themselves.