Function classify::get_head_tail_breaks
source · [−]pub fn get_head_tail_breaks<T: ToPrimitive>(data: &[T]) -> Vec<f64>
Expand description
Returns a vector of breaks generated through the Head-Tail Breaks algorithm given a dataset
Arguments
data
- A reference to a collection of unsorted data points to generate breaks for
Edge Cases
- Inputting large u64/i64 data (near their max values) will result in loss of precision because data is being cast to f64
Examples
use classify::get_head_tail_breaks;
let data: Vec<f64> = vec![1.0/1.0, 1.0/2.0, 1.0/3.0, 1.0/4.0, 1.0/5.0,
1.0/6.0, 1.0/7.0, 1.0/8.0, 1.0/9.0, 1.0/10.0];
let result: Vec<f64> = get_head_tail_breaks(&data);
assert_eq!(result, vec![0.2928968253968254, 0.611111111111111]);