1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use *;
/// Cut continuous data into discrete bins
///
/// # Arguments
/// * `series` - A Series containing continuous data (f64)
/// * `bins` - A vector of bin edges (must be sorted in ascending order)
/// * `labels` - Labels for the bins
///
/// # Returns
/// A String Series with bin labels
pub
/// Find the bin for value using left-closed, right-open [a, b) interval.
///
/// This function determines which bin a value belongs to based on the provided bin edges.
/// It uses a left-closed, right-open interval for all bins except the last one, which
/// includes the rightmost edge to handle the maximum value.
///
/// # Arguments
/// * `value` - The value to find a bin for
/// * `bins` - A slice of bin edges, must be sorted in ascending order
///
/// # Returns
/// The index of the bin that contains the value
///
/// # Examples
/// ```rust,ignore
/// let bins = &[0.0, 1.0, 2.0, 3.0];
/// assert_eq!(find_bin(0.5, bins), 0); // Falls in [0.0, 1.0)
/// assert_eq!(find_bin(1.0, bins), 1); // Falls in [1.0, 2.0)
/// assert_eq!(find_bin(3.0, bins), 2); // Equals right edge, falls in [2.0, 3.0]
/// ```
///