pub fn digitize<T>(
array: &Array<T>,
bins: &Array<T>,
right: bool,
) -> Result<Array<usize>>Expand description
Return indices of bins to which each value belongs
§Parameters
array- Input arraybins- Array of bin edges (must be monotonically increasing)right- If true, intervals include right edge; otherwise left edge
§Returns
Array of indices indicating which bin each value belongs to
§Examples
use numrs2::prelude::*;
let x = Array::from_vec(vec![0.2, 6.4, 3.0, 1.6]);
let bins = Array::from_vec(vec![0.0, 1.0, 2.5, 4.0, 10.0]);
let indices = digitize(&x, &bins, true).expect("digitize should succeed");
assert_eq!(indices.to_vec(), vec![1, 4, 3, 2]);