Skip to content
uniform_bin_edges

uniform_bin_edges

Mojo function 🡭

uniform_bin_edges

fn def uniform_bin_edges(min: Float64, max: Float64, bins: Int) -> List[Float64]

bins + 1 equally spaced boundaries covering [min, max] – the explicit-range form of bin_edges(), and the way to pin two histograms of different samples to the same intervals by hand.

Boundary i is min + (max - min) * i / bins. Both endpoints are assigned exactly so edges[0] == min and edges[bins] == max.

Args:

  • min (Float64): The left edge of the first bin.
  • max (Float64): The right edge of the last bin; must be greater than min.
  • bins (Int): How many intervals to divide [min, max] into; must be positive.

Returns:

List[Float64]: bins + 1 strictly ascending boundaries.

Raises:

Error: bins is not positive, max is not greater than min, either bound is not finite, or the span is so small relative to the bounds that two boundaries round to the same Float64.