Skip to content

bigfunctions > quantize_into_fixed_width_bins

quantize_into_fixed_width_bins

Signature

quantize_into_fixed_width_bins(value, min_bound, max_bound, nb_bins)

Description

Get the bin_range in which belongs value with bins defined so that there are nb_bins bins of same width between min_bound and max_bound plus a bin ]-∞, min_bound[ and a bin ]max_bound, +∞[

Examples

select bigfunctions.eu.quantize_into_fixed_width_bins(-4, 0, 100, 10)
select bigfunctions.us.quantize_into_fixed_width_bins(-4, 0, 100, 10)
select bigfunctions.europe_west1.quantize_into_fixed_width_bins(-4, 0, 100, 10)
+-----------+
| bin_range |
+-----------+
| ]-∞, 0[   |
+-----------+

select bigfunctions.eu.quantize_into_fixed_width_bins(5, 0, 100, 10)
select bigfunctions.us.quantize_into_fixed_width_bins(5, 0, 100, 10)
select bigfunctions.europe_west1.quantize_into_fixed_width_bins(5, 0, 100, 10)
+-----------+
| bin_range |
+-----------+
| [0, 10[   |
+-----------+

select bigfunctions.eu.quantize_into_fixed_width_bins(97, 0, 100, 10)
select bigfunctions.us.quantize_into_fixed_width_bins(97, 0, 100, 10)
select bigfunctions.europe_west1.quantize_into_fixed_width_bins(97, 0, 100, 10)
+-----------+
| bin_range |
+-----------+
| [90, 100] |
+-----------+

select bigfunctions.eu.quantize_into_fixed_width_bins(130, 0, 100, 10)
select bigfunctions.us.quantize_into_fixed_width_bins(130, 0, 100, 10)
select bigfunctions.europe_west1.quantize_into_fixed_width_bins(130, 0, 100, 10)
+-----------+
| bin_range |
+-----------+
| ]100, +∞[ |
+-----------+